How to check whether a filie is existing
Well I am tying to open a file for reading which does not exist and thus getting an erro message. How to check whether a file is existing before I open it for reading?
I am using VB.NET and doing windows application
Well what I would probably do is create a data set with all the files in the directory in it, then check the file name string with the data set. There is probably a more efficient way, but this could make it easier for you if you want to use other information about the file or several files. I can probably post code on how to populate a data set with file info or read from a directory.
You should use the System.IO.File class. It has a shared method called Exists.
' then in the function
If File.Exists(filepath) Then
'dont open it.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)