You can nest try catch blocks.
try
' This is the outer try block
' Do something
dim value as new collection
try
value = my.computer.filesystem.getdirectories(Path & "\" & tbl.Name)
catch e as exception
value = new collection
finally
if value.count > 0 then my.computer.filesystem.CreateDirectory(Path &
"\" & tbl.Name)
end try
' Continue processing in outer try block
catch outerError as exception
end try
An alternate would be to use
my.computer.filesystem.createdirectory(Path)
value = my.computer.filesystem.getdirectories(path & "\" & tbl.Name)
if value.count > 0 then my.computer.filesystem.CreateDirectory(path & "\"
tbl.Name)
or even shorter if you don't care about "value" when you're done (the My
Classes hide a lot of exception handling)
my.computer.filesystem.CreateDirectory(path & "\" & tbl.Name
Mike.
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
"Michael" <Mi*****@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com... Hi Everyone,
I'm using VS 2005 now and would like to know if .Net has a replacement
for the Resume Next clause. I would like to do something like the following:
On Error Resume Next
value = My.Computer.FileSystem.GetDirectories(Path & "\" &
tbl.Name )
if value.Count > 0 then
My.Computer.FileSystem.CreateDirectory(Path & "\" & tbl.Name)
end if
I wanted to see if a Directory existed. But if the main dir is not
there, GetDirectories throws an exception. In this case is good, indicating
that its
not there. But I need to the code to continue without going to the Catch
block. Is there a way to do this. Thanks for any info.
Michael
Hmm, instead of using exception handling for this, it would probably be
wiser to check for the directory manually and then call GetDirectories.
In VB.Net 2003, we would use:
Imports System.IO
...
Dim dir As String = IO.Path.Combine(Path, tbl.Name)
Dim dirs As String()
If Not Directory.Exists(dir)
IO.Directory.Create(dir)
End If
dirs = IO.Directory.GetDirectories(dir) ' or something to that effect...
HTH,
Mythran