How to check file existence? 
Author Message
 How to check file existence?


Quote:
> I am trying to check for the existence of a file using a
> VBScript.  I know it is possible with Perl but I've been
> unable to find complete documentation on how it is done
> with VB.  Thanks!

Use the FileSystemObject's FileExists() method:

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("c:\windows\myfile.txt") Then
    'File exists
Else
    'File doesn't exist
End If



Tue, 10 May 2005 23:47:38 GMT  
 How to check file existence?


Quote:
> I am trying to check for the existence of a file using a
> VBScript.  I know it is possible with Perl but I've been
> unable to find complete documentation on how it is done
> with VB.  Thanks!

objFSO = CreateObject("Scripting.FileSystemObject")
[Or, in ASP: objFSO = Server.CreateObject("Scripting.FileSystemObject")]

If objFSO.FileExists("c:\path\to\my.file") Then
        '...
End If



Tue, 10 May 2005 23:59:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Check existence of file

2. Newbie - Check for file existence

3. Check for the existence of the file

4. checking for existence of file

5. A2K Check for Existence of Back End File

6. Checking for the existence of a file

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

8. Check File Existence?

9. Checking for the Existence of a File

10. Checking for random file existence in Visual Basic

11. Checking for existence of a file???

12. Check for existence of a file?

 

 
Powered by phpBB® Forum Software