Checking for existence of a file... 
Author Message
 Checking for existence of a file...

How do I check if there are files inside a directory using VB 5?
ttyl


Tue, 26 Jun 2001 03:00:00 GMT  
 Checking for existence of a file...
MyFile = Dir("C:\myfile.txt")
If Len(MyFile) Then
    ' got a hit
    End If
Quote:

>How do I check if there are files inside a directory using VB 5?
>ttyl



Tue, 26 Jun 2001 03:00:00 GMT  
 Checking for existence of a file...
Well, you could also use a couple of other methods...such as the FileSystem
Object

Private Function CheckExist(filename as string)
 set fs=CreateObject("Scripting.FileSystemObject")
 CheckExist=fs.fileexists(filename)
End Function

You would call the function like so...

If CheckExist(c:\myfile.txt) then
 msgbox("file exists!")
Else
 msgbox("file doesn't exist...")
End If

There are lots of other keywords in the FileSystemObject that are useful.  Just
thought I'd throw in my 2 cents worth



Fri, 29 Jun 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

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

2. Checking for existence of a file???

3. Check for existence of a file?

4. Checking the Existence of a File

5. A2K Check for Existence of Back End File

6. Checking for the existence of a file

7. Check File Existence?

8. Checking for the Existence of a File

9. Checking for random file existence in Visual Basic

10. Check for the existence of a file.

11. Newbie Question: File existence checking

12. file existence check

 

 
Powered by phpBB® Forum Software