Re: Replacement for Resume Next
- From: "Larry Lard" <larrylard@xxxxxxxxxxx>
- Date: 15 Dec 2005 09:23:52 -0800
Michael wrote:
> 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.
You could wrap just this line in a Try Catch block. However, it's a
good idea to avoid using exceptions as error handlers when there are
alternatives. In particular here, do you have a reason to avoid the use
of My.Computer.FileSystem.DirectoryExists?
Dim sTableDirectory As String = Path & "\" & tbl.Name
If Not My.Computer.FileSystem.DirectoryExists(sTableDirectory) Then
My.Computer.FileSystem.CreateDirectory(sTableDirectory)
End If
--
Larry Lard
Replies to group please
.
- Prev by Date: Re: Replacement for Resume Next
- Next by Date: Re: Replacement for Resume Next
- Previous by thread: Re: Replacement for Resume Next
- Next by thread: Re: Replacement for Resume Next
- Index(es):
Relevant Pages
|