I want to run a check to see if a text file exists on my c:\drive.
If i need to declare the function please include this in help.
Thanks
Printable View
I want to run a check to see if a text file exists on my c:\drive.
If i need to declare the function please include this in help.
Thanks
VB Code:
Public Function FileExists(File As String) As Boolean Dim fLen As Integer On Error Resume Next fLen = Len(Dir$(File)) If Err Or fLen = 0 Then FileExists = False Else FileExists = True End If End Function ' Usage: If FileExists(App.Path & "\file.txt") Then ' Do whatever here End If
won't the dir command work also?
The above method is probably a bit more solid, but also much larger.
VB Code:
if dir("C:\text.txt") = "" then do something
= "" means it doesn't exist otherwise it does.