LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make MakeDir() not cause a run-time error? or How to detect if a directory exists...

I am using the MakeDir() function to create a new directory, and most of the time the directory already exists so the function returns -9, which is all well and good, I can just ignore it. However, while testing my program in debug mode the MakeDir() function will register a non-fatal run-time error message which pops up with a box and I have to select "continue" each time. This is really annoying considering my program calls MakeDir every few seconds!
So is there:
1) A way to detect if an existing subdirectory already exists (and hence only call MakeDir if it doesn't exist)
or 2) Stop the damn MakeDir() function from generating a run-time error while debugging!
 
Thanks
Dave 🙂
0 Kudos
Message 1 of 3
(3,684 Views)

Hi Dave.

  1. I believe that FileExists() works for directories as well as files. If not, you could check for the existence of "." or ".." in the directory.
  2. Try the menu selection Run/Break On/Library Errors, or call SetBreakOnLibraryErrors() before and after the MakeDir() call.

Regards,
Colin.

 

0 Kudos
Message 2 of 3
(3,674 Views)

FileExists ("R:\\Data.TXT", &fileSize);

if (fileSize == (-1)) {      ...       }

 

This code tests if the Ramdisc is initialized and if thefile exists.

 

No Runtime error!

 

0 Kudos
Message 3 of 3
(2,656 Views)