VBStudent
asked on
Checking for the existence of a File
Hi, I am using Visual Basic 2005. I am trying to check for the existence of a file. Apparently, I am not importing the correct libraries because FileExists is not recognized. Any suggestions of syntax would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was a slick solution. Thank you for your quick response
Um...thanx.
Though it really isn't any better/worse than ch2's submission.
It just uses a different namespace...
There are LOTS of goodies in the "My" namespace though.
My.Application:
http://msdn2.microsoft.com/en-us/library/ms172938.aspx
My.Application.OpenForms:
http://msdn2.microsoft.com/en-us/library/eh13dca9.aspx
My.Computer:
http://msdn2.microsoft.com/en-us/library/ms172948.aspx
and lots of other stuff...
Though it really isn't any better/worse than ch2's submission.
It just uses a different namespace...
There are LOTS of goodies in the "My" namespace though.
My.Application:
http://msdn2.microsoft.com/en-us/library/ms172938.aspx
My.Application.OpenForms:
http://msdn2.microsoft.com/en-us/library/eh13dca9.aspx
My.Computer:
http://msdn2.microsoft.com/en-us/library/ms172948.aspx
and lots of other stuff...
Try this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Path As String
Try
Path = "yourfilepath"
If IO.File.Exists(Path) Then
MsgBox("File exists")
Else
MsgBox("File dosen't exists")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
ch2