Checking for the Existence of a File 
Author Message
 Checking for the Existence of a File

Hi
I would be grateful if some one would help me find the Dot Net Visual Basic
equivalent of
"If Len(Dir$("C:\Fixtures.Seq")) Then"
With thanks in anticipation
Roget Stenson


Sun, 16 Jan 2005 06:17:18 GMT  
 Checking for the Existence of a File
Use a Try/Catch
Try
    IF len(DIR("C:\FIXTURES.SEQ")) > 0 then
            .....
    end if
catch e as exception
    messagebox("File not found")
end try

goes something like that.


Quote:
> Hi
> I would be grateful if some one would help me find the Dot Net Visual
Basic
> equivalent of
> "If Len(Dir$("C:\Fixtures.Seq")) Then"
> With thanks in anticipation
> Roget Stenson



Sun, 16 Jan 2005 06:34:53 GMT  
 Checking for the Existence of a File
If New System.IO.FileInfo("C:\Fixtures.Seq").Exists Then

HTH

David


Quote:
> Hi
> I would be grateful if some one would help me find the Dot Net Visual
Basic
> equivalent of
> "If Len(Dir$("C:\Fixtures.Seq")) Then"
> With thanks in anticipation
> Roget Stenson



Sun, 16 Jan 2005 06:38:12 GMT  
 Checking for the Existence of a File
I recommend using the System.IO.FileInfo object, you can do the same for
directories with the System.IO.DirectoryInfo object

--
Paul Hetherington
BTech (Applied Computer Science)

Lead Programmer/Analyst-Graphics
VS Visual Statement Inc
www.visualstatement.com


Quote:
> If New System.IO.FileInfo("C:\Fixtures.Seq").Exists Then

> HTH

> David



> > Hi
> > I would be grateful if some one would help me find the Dot Net Visual
> Basic
> > equivalent of
> > "If Len(Dir$("C:\Fixtures.Seq")) Then"
> > With thanks in anticipation
> > Roget Stenson



Sun, 16 Jan 2005 06:56:35 GMT  
 Checking for the Existence of a File

Quote:
> I would be grateful if some one would help me find the Dot Net
> Visual Basic equivalent of
> "If Len(Dir$("C:\Fixtures.Seq")) Then"

System.IO.File.Exists

Armin



Sun, 16 Jan 2005 17:24:41 GMT  
 Checking for the Existence of a File
Imports System.File.IO

Then, you can use the shared Exists() method to look for a specific file.
With
the File class, you pass in the path as a string, like so:

If File.Exists("c:\myfile.txt") Then
    MessageBox.Show("File found.")
Else
    MessageBox.Show("File not found.")
End If


Quote:

> > I would be grateful if some one would help me find the Dot Net
> > Visual Basic equivalent of
> > "If Len(Dir$("C:\Fixtures.Seq")) Then"

> System.IO.File.Exists

> Armin



Sun, 16 Jan 2005 20:43:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Checking for the existence of a file

2. Check for the existence of a file.

3. Check for the existence of the file

4. A2K Check for Existence of Back End File

5. How to check for existence of a file on harddisk form OL VBscript

6. Check File Existence?

7. Checking for random file existence in Visual Basic

8. Checking for existence of a file???

9. Check for existence of a file?

10. Checking for existence of a file...

11. Checking the Existence of a File

12. Newbie Question: File existence checking

 

 
Powered by phpBB® Forum Software