LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File not writable after building executable

Solved!
Go to solution

I have an application I've been developing to allow the user to modify options stored in a configuration file. The file is a simple text file and is read upon my VI startup, and saved when the VI is closed. This all happens correctly when I'm running within the Labview development environment.

 

However, when I build my application to EXE, the write operation does not appear to be happening when my application closes. Why is this?

 

The file is included in the build and put into the \data directory. I have a VI that just returns the full path/filename to my configuration file, and I know it's returning the proper path because the configuration is read properly on startup. I'm using a VI called "Current VI's Path (VI or exe).vi", which I did have to modify to perform one more strip path operation to get the proper path after my EXE was built.

 

I'm running right out of the folder the application was dropped into by the Labview build process. The configuration file and all parent folders are not read-only. The build folder is on my desktop.

 

Why does my write operation fail? I don't get any error messages or anything.

 

Thanks.

 

As a side note, it's interesting that the post message spell checker's dictionary doesn't include the word "Labview"...

0 Kudos
Message 1 of 4
(2,346 Views)
Solution
Accepted by topic author Xooch

I would do two things:

1. I think this was introduced in 2009, but use the Application Directory constant instead of the Current VIs path constant. It makes live easier.

2. Can you try this on a fresh VI that doesn't have anything execpt the open and close of the INI file and see if that works. That should instantly make you realize where the application must be going wrong.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
Message 2 of 4
(2,339 Views)

I will give that a shot in a little bit.

 

As a note, I'm not using an INI file, but a text file, using open for read/read/close and open for write/write/close.

 

0 Kudos
Message 3 of 4
(2,333 Views)

@adnan Z wrote:

I would do two things:

1. I think this was introduced in 2009, but use the Application Directory constant instead of the Current VIs path constant. It makes live easier.

2. Can you try this on a fresh VI that doesn't have anything execpt the open and close of the INI file and see if that works. That should instantly make you realize where the application must be going wrong.


Turns out your very simple (and oft overlooked by me) idea in #2 was key to finding out why this wasn't working. It turns out that writing to a file worked fine. The state machine I was using was making a decision based on whether I was running in the development environment or as an executable and not even running the state that contained the write operation. It's fixed now.

 

And thank you for pointing out the Application Directory constant. Much better than what I was using before!

 

Steve

0 Kudos
Message 4 of 4
(2,320 Views)