LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

change file directory / how to transfer files between two computers"

Hi,

I "created" a program which writes some .dat files. I'm using the fopen and fclose instructions.

My problem is that all the .dat files are created but impossible to change the folder destination.

 

My question is, how I could create and save my files in another folder directory than the root of my program?

Do I change my coed and use wrilefile instruction instead of fopen?

 

My second question is, what is the best way to transfer these files to another computer? Ethernet port, RS232, USB?

I'm a little bit lost, could you help me please?

 

Regards,

 

0 Kudos
Message 1 of 6
(3,192 Views)

Your question is a little bit puzzling as the parameter file_name in fopen allows for absolute and relative path names. So you can use any valid path such as

 

fopen ( "\\Users\\Wolfgang\\Documents\\data.txt","w"). All you have to note are the double backslash characters. Does it not work for you?

0 Kudos
Message 2 of 6
(3,190 Views)

Hello Wolfgand,

thank you for your answer. Yes it works !!!! Now, I have another question. I'm using DirSelectPopup to save a new file path and using this method with my new files to save them in this new folder.

 

DirSelectPopup ("", "Select Directory", 1, 1, szFilePath);

 

But, when I see the value of the szFilePath, I don't have a double backslash characters... How I can to transform szFilePath to be compatible with fopen?

Should I have to read all characters of szFilePath and change a simple backslash to a double backslash?

 

Regards

0 Kudos
Message 3 of 6
(3,182 Views)

You can use the file name obtained from DirSelectPopup as is, the file name is valid (of course).

 

Only if you want to enter some special escape sequence characters yourself, such as a carriage return or a backslash, you need to code it in a special way, e.g.

\n  newline

\r   carriage return

\\   backslash

...

 

You will find more about this C behavior in every book or course about this programming language, one, without preference, can be found here

0 Kudos
Message 4 of 6
(3,176 Views)

I can only add that using MakePathname command can help in building up a pathname starting from the path returned from DirSelectPopup and your own file name: with this command you won't have to struggle about special characters while building the string.



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?
0 Kudos
Message 5 of 6
(3,171 Views)

Thank you guys!!! I used the MakePathName and it works!!! (and please excuse me for my bad english)

 

Best Regards,

 

0 Kudos
Message 6 of 6
(3,163 Views)