LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

file not found when using write characters to file

OK, I am missing something really basic here.  Whenever I try to use the Write Characters to File function, if I try to give it a path beyond the C:\filename directory, it returns an error.  In other words, C:\Dan works, but C:\Dan\Test reurns an error. WHAT am I missing?
0 Kudos
Message 1 of 5
(2,978 Views)
The VI you are calling does not create directories. It assumes that the directory exists and it is going to write (or append) to a file. Also, the path should contain the file name as well. For example: c:\Dan\Test.txt or something similar. In the example you give, the routine would have created a file named Dan (no file extension) in C root. The second failed because I'm guessing that the subdirectory Dan doesn't exist.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 5
(2,977 Views)
OK, I'm still confused.  According to the help for the function, "If Append to File? is TRUE, the VI appends data to an existing file. If Append to File? is FALSE, the VI replaces data in an existing file.
If there is no existing file, the VI creates a new file. The default is FALSE. So, why doesn't it create the file if it doesn't already exist?  I want to create a new file each day, with part of teh file name being the date.  So far, the only way it works is to create a file at the Root directory.  If I try creating a file in a folder on the C Drive, or better yet, within a folder insode another folder, in yet a third folder on the C Drive, it does not work.  Help?!
0 Kudos
Message 3 of 5
(2,972 Views)
I think I get it...it will create a file, but not a folder...is that correct?  I cannot create a path and create folders and subfolders along the way?
0 Kudos
Message 4 of 5
(2,971 Views)
Bingo! That is the problem. You have to make sure the directory exists before you attempt to write files to it.

     BTW: In LV there is a function for creating folders programatically. A good way to see if a directory exists is to attempt to list its
               contents. If the list function returns an error, the directory doesn't exist and you have to create it.

So make use of the error that the file write returns. If you get an error, start at the root of your path and test to see if each level exists, and if not create it. When you have all the folders in place repeat the file save.

Mike...

Message Edited by mikeporter on 05-24-2007 12:55 AM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 5
(2,964 Views)