Existence of a file

  • Thread starter Thread starter Jaime Lucci
  • Start date Start date
J

Jaime Lucci

Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks
 
It's not too much different than VB 6.

If IO.File.Exists("PathToFile") then
'File Exists - Do whatever you need to do
Else
'File does not exist...
End If

The File Class in the System.IO namespace has a bunch of shared methods
that are very useful. There's also a Directory class in the IO
namespace that you may find useful when dealing with directories and
files. Many of those methods are shared too, so you don't need to
worry about instantiating an instance of the File and/or Directory
classes.

Derek Woo
 
System.IO.File.Exists()

Hi.

How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Thanks
 
Jaime Lucci said:
How can I do to know if a file exists or not in my disc? In VB6 I used to
use the FileExists command.

Although VB6 didn't have a built-in 'FileExists' command, you can use
'System.IO.File.Exists' or 'System.IO.FileInfo.Exists' instead in VB.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top