LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Config File in ProgramFiles

I have a VI that uses a config file to store various set up data.
 
I'm currently saving it to a constant location. What I'd like to do is save the config file in the same location as the exe, could anyone point me in the correct/best way to go about this?
 
Thanks
 
Derek
0 Kudos
Message 1 of 4
(2,827 Views)
Hi Derek,

use "path to vi" constant from file palette and strip filenames until you have an directory... (In an exe you have to strip one level more as all vis are inside a library!)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,819 Views)

Thanks GerdW for replying once again  Smiley Happy

 

Turned out I was being silly... whilst trying to get the attached working, I'd placed a path indicator but hadn't expanded it. Thought the path node was only giving me c:\ when in fact it had just wrapped to the next line so I couldn't see the rest of the path.

Your post did remind me to strip that extra layer off the path though.

 

Thanks again

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

An additional couple of points:

It's better to do this is using a loop, stripping the path with a shift register and using the File\Folder Info primitive to check if the path is a directory. OpenG has a VI which does this, as well as many other useful VIs.

With Windows Vista there are some changes in the permissions users have. I'm not sure about the details, but essentially, you should not have write access to the executables directory. To get around this, you might wish to save your settings in the data directory. In Windows, this is APP_Data, but LV uses My Documents\LabVIEW Data for some reason, at least by default.


___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,789 Views)