LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What if the Result is -9 in MakeDir(arg)

MakeDir ("C:\\DATA");
assume the directory DATA exists.

Using the function MakeDir works great. It assumes that the directory does
not exist. If the directory does exist, the return is -9. There is a break
from the program. How do you get around this break and stay in the program
?
0 Kudos
Message 1 of 4
(3,815 Views)
"Lou Eichner" wrote:
>>MakeDir ("C:\\DATA");>assume the directory DATA exists.>>Using the function
MakeDir works great. It assumes that the directory does>not exist. If the
directory does exist, the return is -9. There is a break>from the program.
How do you get around this break and stay in the program>?
I assume this happens only in debugging mode.
This probably means you have "break on library errors" checked in the options-menu.
Uncheck it and the debugger won't break.

Good luck,
Steven Wellink
0 Kudos
Message 2 of 4
(3,814 Views)
Hello, Lui.

You can use something like this code:

int oldBreakState, result;

oldBreakState = SetBreakOnLibraryErrors (0); // disables break on
error
result = MakeDir ("C:\\DATA");
SetBreakOnLibraryErrors (oldBreakState); // restores the old
'break' state
if (result != 0)
{
// process errors
}

--
Yuri Gendelman
ygendel@birinc.com



Lou Eichner wrote in message
news:39cae397@newsgroups.ni.com...
>
> MakeDir ("C:\\DATA");
> assume the directory DATA exists.
>
> Using the function MakeDir works great. It assumes that the directory does
> not exist. If the directory does exist, the return is -9. There is a break
> from the program. How do you get around this break and stay in the program
> ?
0 Kudos
Message 3 of 4
(3,814 Views)

I know this is an old thread.  But I just want to reply in case someone is interested.

You may not want to create a new directory if it already exists.  Try this:

fileIsExisting = FileExists(buf, 0);  // buf is the directory you want to create
if (!fileIsExisting)               
   MakeDir (buf);        

Smiley Happy

-shylah

 

 

0 Kudos
Message 4 of 4
(3,605 Views)