Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject is lying!

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I am using the following code to check to see if a text file exists.
Code:
Log
is a subroutine I wrote that logs a message to a log file.
The code jumps into the If statement to indicate that the file does not exist, although if I open up the log file or look at the message box, I could manually open up the file, whose full path is stored in the variable
Code:
strInfoFilePath
and I can also do DIR command from a command prompt on that file. Why does the
Code:
FileSystemObject
think the file does not exist??

The file was created from
Code:
FileSystemObject
using the
Code:
OpenTextFile
command with a create=True from another script and that file was also closed first.

Code:
Dim objFileSystemObject, strInfoFilePath

strInfoFilePath = PACKAGEFILE_DIR & "\" & INFO_FILE

Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")

'First check to see if the INFO_FILE exists    
If Not objFileSystemObject.FileExists(strInfoFilePath) Then
    Call Log(strInfoFilePath & " not found.")
    Call MsgBox(strInfoFilePath & " not found.")
End If
 
Does the full path you refer to include the drive letter?


Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Just find out that strInfoFilePath has not been initialised properly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top