|
-
Jul 10th, 2000, 01:12 PM
#1
Thread Starter
Frenzied Member
can somone please tell me how to cheack if a file exsits.
please make it as simple as possible becuase I'm still sleeping although its 2:10 in Rhode Island
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 01:14 PM
#2
Hyperactive Member
Try this:
Code:
Dim fso
Set fso=CreateObject("Scripting.FileSystemObject")
If fso.FileExists("c:\windows\desktop\myFile.txt")=True then
msgbox "I'm here"
Else
msgbox "File not present"
end if
-
Jul 10th, 2000, 01:20 PM
#3
Code:
Function VBDoesFileExist(FilePath As String) As Boolean
On Error Resume Next
Dim strRet As String
' see if the file exists
strRet = Dir$(FilePath, vbNormal Or vbSystem Or vbHidden Or vbReadOnly)
' check to make sure the handle isnt invalid
If strRet <> "" Then
VBDoesFileExist = True
Else
VBDoesFileExist = fale
End If
' use:
' VBDoesFileExist(c:\windows\desktop\myilfe.txt)
End Function
this is better because it doesnt require the reference to the scripting host.
-
Jul 10th, 2000, 01:23 PM
#4
Thread Starter
Frenzied Member
whats the diffrence? to me one is longer, one is shorter.
Sorry, if I'm dont getting it right now becuase I am tried, the first one seems simple any easy for me.
NXSupport - Your one-stop source for computer help
-
Jul 10th, 2000, 01:23 PM
#5
You can use the Dir Function.
Code:
RetVal = Dir("C:\MyFile")
If RetVal <> "" Then
MsgBox ("File Exsists")
Else
MsgBox ("File Does not exsist")
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|