LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

checking to see if a folder exists

Hello,
 
  I am trying to save a file to a directory and if the directory does not exist I want to create it.  I have attached an image of a simple vi.  My problem is that when I run the vi and the directory does not exist I get a pop-up error window #7 that says the file was not found.  If I press continue my vi will behave normally and create the directory and file.  The strange thing is, I did a search and found someone with this problem and there was an example file DirTest.vi that someone created.  That file works fine, I do not get an error#7 pop-up window.  But when I try to create the same vi on my machine I get the Error #7 pop-up window.  I have LV version 8.0 and updated to 8.0.1 and I still have the same problem.
 
Thanks for any help. 
0 Kudos
Message 1 of 8
(4,350 Views)
Wire the error clusters and handle the errors programmatically. You can also turn off the automatic error handling (Options >> Block diagram...), but you need to make sure that you handle the errors or your program may behave in ways you do not expect.

Lynn
Message 2 of 8
(4,338 Views)

Thanks for the info.  But I still have the question of why the example I downloaded works fine but when I create the vi it gets an error.  Could there be a problem with my LabView installation?  I do not know what version the example was made in, but it works, so could it be a LV 8 problem?

Bryan

 

0 Kudos
Message 3 of 8
(4,332 Views)
"Enable automatic error handling" can be set on a per-VI basis (File->VI Properties->Execution). It would seem that you have this enabled by default, but that it is disabled in the file you downloaded.
0 Kudos
Message 4 of 8
(4,328 Views)
That was it.  Thanks for the info.  I guess I have to get better at dealing with error handling.  I am still new at LV and have slacked off in dealing with error handling.  I looked in the examples section of LV and did not find any info on error handling.  Where would be a good place to start with error handling?
0 Kudos
Message 5 of 8
(4,324 Views)
I don't worry much about error handling myself. My understainding is that with automatic error handling turned on, the VI acts just like you wired a Simple Error Handler to the Error Out terminal of the New Directory function.

If you really want your VI to do something other than just pop-up with a message when it encounters an error, then I suppose you're just going to have to decide what errors you are likely to encounter and what you might want to do if such errors are encountered.

Message Edited by kehander on 07-12-2006 01:40 PM

0 Kudos
Message 6 of 8
(4,317 Views)
This would be a better way to do what you're trying to do.  You want to check the error of the File/Directory Info VI for that error code 7 that you get.  This tells you that the file or folder doesn't exist, then you create it.  This way, you won't have to turn off error handling.  This is how I always check if a file exists.
 

Message Edited by Marc A on 07-12-2006 02:58 PM

Message 7 of 8
(4,311 Views)
Thanks Mark, that should work out fine.
0 Kudos
Message 8 of 8
(4,304 Views)