LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I check if a directory already exist

Hello,
 
I have Labview 7.1 on an windows XP.
I want to check if a directory exist in order to decide whether to create it or not.
 
Thanks
0 Kudos
Message 1 of 14
(3,993 Views)
Do you mean a normal directory in windows? In windows desk Click on Start -> Search -> For Files or Folders and insert the directory name. i hope it helps.
0 Kudos
Message 2 of 14
(3,984 Views)

Hi,

you could use the LIST Directory vi (File I/O => Advanced). It would return the list of directories (or files) at a certain path.

Search the array of directories for the directory name you want to check.

Dai

Dai

LV 7.1 - WIN XP - RT - FP
0 Kudos
Message 3 of 14
(3,983 Views)
You can also feed the path into File\Directory Info and check the Directory output (or the error output) or you can simply feed the path into New Directory - if the directory exists it will not be created and an error will be returned.

___________________
Try to take over the world!
0 Kudos
Message 4 of 14
(3,976 Views)

Many thanks to all of you.

I hoped to get a solution that don't prompt the user with an error message.

 

 

0 Kudos
Message 5 of 14
(3,966 Views)
If you wire the error terminal into anything, the message won't appear to the user. In general, it's very important for programs to handle errors on their own. In this case, you can check the error number and if this specific error occurs ignore it.

___________________
Try to take over the world!
0 Kudos
Message 6 of 14
(3,959 Views)

Hello,

Attached is an example; specify a directory in the only front panel control and if it exists, it will tell you, and if the directory doesn't exist but you specify a path which exists up to the last directory specified, it will create that directory.  If you specify a path which doesn't exist (where the only non-existent part is NOT simply the final directory specified in the path), then it will tell you that the path couldn't be found.

Hope this helps!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 7 of 14
(3,943 Views)

The best thing you can do is go into your LV options and turn off automatic error handling. It is very bad because the only options you have are to ignore the error, or stop your program immediately with no deinitialization, just stop. Very bad. The folks in Austin should be thinking up ways to help people to write good code, not simplifying the process of writing bad.

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 8 of 14
(3,941 Views)

Mike, I'm not sure that's the best thing to do.

A while back someone posted a question about "why doesn't this work?". His application was very big, even after he cut it down, so even starting to help him was hard, because we couldn't understand what the proper operation of the program was. The only clue we had to go on was automatic errors, which he didn't see, because he turned off the auto handling (he thought there was no need to take care of property node errors). So he didn't see the errors, and I had trouble understanding them because I didn't know what the app was supposed to do.

The moral of that (other than the obvious one) was to leave the auto handling on. Since it only kicks in if you didn't wire the error cluster out, it will not change the behaviour if you are handling errors and it will allow you to know you have errors in case you forgot. Obviously, you can say that leaving it on will cause people to "forget" error handling, but that's already a psychological discussion.


___________________
Try to take over the world!
0 Kudos
Message 9 of 14
(3,919 Views)
I hear what you are saying, but I have seen too many deveopment projects that got completely out of control because the developers didn't feel it was imporant enough to include error handling. To me the issue is very fundamental. If you are going to produce usable code you need to incorporate error handling that is systematic and systemic. That's just what it takes to get the job done.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 10 of 14
(3,912 Views)