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:34 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.
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.
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.
05-25-2012 04:01 PM
I've done something similar but watch the error cluster wire, usually it is used to direct the dataflow (I just wire the path and error cluster wires throught the True case).
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.