05-25-2012 11:28 AM
I have a small vi that reads from a file on the root drive. If the file is not there, it creates it. First off, the vi is halting at build path icon. This icon is flashing for some reason, but no warning is given. It's as if there is a break point there, but I didn't put one there, and I don't see one. Then, when it continues, it fails to create the non-existing path and file. I've attached the vi in question. BTW, this is LV7.0. Thanks.
Solved! Go to Solution.
05-25-2012 11:35 AM
I manually created the path and it works fine. Why, if it's creating the file, doesn't it create the path as well? I've done this using other paths and it has worked.
05-25-2012 11:47 AM
I even tried programmatically creating the folder with "New Directory" but that gives the same error 7. I have administrative rights on my computer, so it should allow me to create the folder in question. The OS is Windows XP.
05-25-2012 12:14 PM
I figured it out. It will only create one directory at a time. I had to convert the directory path into an array and create each directory in sequence.
05-25-2012 12:34 PM
@rickford66 wrote:
I figured it out. It will only create one directory at a time. I had to convert the directory path into an array and create each directory in sequence.
When you do that take a good care of the first element in the array, it will be C and not C: so if you autoindex a for loop for the case i=0 you need to add the colon to the indexed string.
Ben64
05-25-2012 01:20 PM
I just put it back together with the Build Path function and it works.
05-25-2012 03:39 PM
I just found out that if you use an empty path constant to the base path input of the Build Path function and C to the name or relative path input it will create the base path C:\.
In your vi you should use the "Check if File or Folder Exist.vi" (from the File IO -> Advanced File Functions palette) to select the TRUE or FALSE case instead of the error output of the open file function.
Ben64
05-25-2012 03:48 PM
Here's what I have....
05-25-2012 04:01 PM
05-25-2012 04:32 PM
Not sure if your icons are the same as mine, but my File Info function throws an error if the folder does not exist. Therefore, I don't feed that error through, I just "absorb it" by feeding it to the unbundle cluster. Probably not the best programming technique, but it silences it. Also, the New function will return an error if the directory already exists. The behavior I want is for it to create the folder if it does not exist. If it exists, then do nothing.