"Brian Henry" <no****@nospam.com> schrieb
That traps all IO errors though... I just want something when the
file is locked to say something like "You already have this file
open, please close it and try agian" before you could do this with
error codes, with exceptions you dont seem to have them anymore that
I know of
I still want IO errors like file not found and stuff to throw
exceptions outside of the one i already mentioned
You wrote that you want to catch only IOException, not all other exceptions.
That's what the example does.
You could rethrow the exception if it's one of the exceptions derived from
IOException: (untested)
try
'code
catch ex as ioexception
if ex.gettype is gettype(ioexception) then
'message here
else
throw
end if
end try
Another way:
const ERROR_SHARING_VIOLATION as integer = 32
try
'code
Catch ex As IOException When
System.Runtime.InteropServices.Marshal.GetLastWin3 2Error =
ERROR_SHARING_VIOLATION
'message
end try
However, I'm not sure whether error #32 is the only error that indicates a
sharing violation.
Armin