squirleegirl
Programmer
Hello! I am so frustrated right now!!!! I have some code that filters through a directory looking for a certain named file. If it finds it, then it opens it up, reads it into a variable then deletes the file.
However, right now I can't get past the if file exists part (this program is a VB program converted to ASP). I KNOW some files exist - I have intentionally placed some out there. Here is my code:
Set fsoObject = CreateObject("Scripting.FileSystemObject")
Do While Not rst.EOF
count = count + 1
If fsoObject.FileExists("\\server\path\" & rst("record") & "\flag.txt") = true Then
Set f = fsoObject.GetFile("\\server\path\" & rst("record") & "\flag.txt")
Set fsostream = f.OpenAsTextStream(ForReading)
Do While Not fsostream.AtEndOfStream
strline = fsostream.ReadAll
Loop
fsostream.Close
'f.Delete (don't delete until it works!)
Else
'do nothing
End If
rst.movenext
Loop
rst.Close
I know my database record is correct. I've tested and had it print each path it is looking for and they are all correct. It will not get past the if fsoObject.fileexists part - well, more correctly it is not recognizing it as existing - it automatically skips the if and goes to the else. It does loop through all my records though. I've tried if fileexist = true and just if fileexists. I've tried if folderexists on the folder and if so then get the file, but doesn't work either. UGH!!!!! =-)
Does anyone have any ideas?
Thanks in advance - Squirleegirl
However, right now I can't get past the if file exists part (this program is a VB program converted to ASP). I KNOW some files exist - I have intentionally placed some out there. Here is my code:
Set fsoObject = CreateObject("Scripting.FileSystemObject")
Do While Not rst.EOF
count = count + 1
If fsoObject.FileExists("\\server\path\" & rst("record") & "\flag.txt") = true Then
Set f = fsoObject.GetFile("\\server\path\" & rst("record") & "\flag.txt")
Set fsostream = f.OpenAsTextStream(ForReading)
Do While Not fsostream.AtEndOfStream
strline = fsostream.ReadAll
Loop
fsostream.Close
'f.Delete (don't delete until it works!)
Else
'do nothing
End If
rst.movenext
Loop
rst.Close
I know my database record is correct. I've tested and had it print each path it is looking for and they are all correct. It will not get past the if fsoObject.fileexists part - well, more correctly it is not recognizing it as existing - it automatically skips the if and goes to the else. It does loop through all my records though. I've tried if fileexist = true and just if fileexists. I've tried if folderexists on the folder and if so then get the file, but doesn't work either. UGH!!!!! =-)
Does anyone have any ideas?
Thanks in advance - Squirleegirl