NI Home > Community > NI Discussion Forums

LabWindows/CVI

Reply
Member
Gold5
Posts: 6
0 Kudos

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,

 

Trusted Enthusiast
Wolfgang
Posts: 2,523
0 Kudos

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

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?

Member
Gold5
Posts: 6
0 Kudos

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

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

Trusted Enthusiast
Wolfgang
Posts: 2,523
0 Kudos

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

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

Proven Zealot
RobertoBozzolo
Posts: 5,196
0 Kudos

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

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 Zone Community
________________________________________
If I have helped you, why not giving me a kudos?
Member
Gold5
Posts: 6
0 Kudos

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

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

 

Best Regards,