LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I save a specific path when saving a file in LabWindows CVI?

I want to be save a path to a file and not have the application revert to a default directory.
0 Kudos
Message 1 of 3
(3,555 Views)
Usual commands to create and open files can accept normally a full pathname, so you can place your file wherever you want on your machine or even on a network drive if wanted. If you specify only the filename your file will be placed in the application directory, but you can always specify the full pathname or the file to be treated.

If you choose a file to open using FileSelectPopup you retrieve the full pathname of the file, so even in this case your file can be wherever you want. The same if you use DirSelectPopup to let the operator choose the location of the file to save/retrieve.

Unless I have not understood your exact problem, it seems to me there is no problem in placing a file on a specific directory on disk, provided the pathname is correc
tly built.

In case this is not your actual problem, please add some more details for us to understand and help you.

Hope this helps
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,555 Views)
If you want to save the pathname and make it default, it is useful to create
an ini file.
Youcan save the complete pathname (includng the backslash characters using
the
Ini_PutRawString () function (it is in the "Reading-writing ini files fp")
as the standard PutString function misinterprests the backslash character in
the path name and uses it as control code.
The ini file can be loaded by the main program and set teh current directory
according to the saved velue

Ini_Text Defaults;
Defaults = Ini_New (0);//creates an unsorted in memory ini ascii database
//at the start, read the ini file containing the default values using the
Ini_ReadFromFile ();
if missing, create an in file programatically, and save it like below:
//find out what is your default directory or
specify it yourself, that save
the data into in meory ini database you can use funtions from the Utility
library directory utilities toolset for this.

Ini_PutRawString (Defaults,"DEFAULT_DIR","PATHNAME","c:\current dir\my
default directory and \filename.tmp") ;
Ini_PutRawString (Defaults,"DEFAULT_DIR","DRIVENAME,drivename) ;
//you may parse the pathname if you need it and store it as before, the
result will be something along these lines:
Ini_PutRawString (Defaults,"DEFAULT_DIR","DRIVENAME",drivename);
Ini_PutRawString (Defaults,"DEFAULT_DIR","DIRNAME",dirname)
....
....

[DEFAULT_DIR]
PATHNAME="c:\current dir\my defaultdirectory and \filename.tmp"
DRIVENAME="c:"
DIRNAME="\current dir\my defaultdirectory and\"
FILENAME="filename.txt"
//I am not sure the exact location of backslash characters, watch the
location of backslash charaters, make sure that are properly placed

To read the pathname data use the Ini_GetRawStringIntoBuffer() function
whichever element you need.

Update the da
ta if changed during program run, and when exiting save the ini
file with the current data using standard file name and location, that you
can find when restart your program.

good luck

Lajos
0 Kudos
Message 3 of 3
(3,555 Views)