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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a FileSystemObject

Status
Not open for further replies.

Claypole

Programmer
Aug 22, 2002
12
0
0
GB
Please can someone tell me why my code isn't working.
I have changed everything 3 times and then used the code from the FAQ. However it it doesn't find the file I get the error message and when it does it does nothing.
The oVisit is just my VB Com object sub which prints to an error file. The filename is correct and it just hangs there

Code as follows
dim fsoObj, sFileName
Const ForReading = 1
Const TristateFalse = 0

sFileName = Server.MapPath ("../updates/csv/CustomerRecords.txt")
oVisit.Common.logError err, "FileName="&sFileName

set fsoObj = Server.CreateObject("Scripting.FileSystemObject")

if fsoObj.fileExists(sFileName) then
dim objTextFile
set objTextFile = fsoObj.OpenTextFile(sFileName)
while not objTextFile.AtEndOfStream
strBuffer = objTextFile.ReadLine
oVisit.Common.logError err, "File Found Hurrah" & strBuffer
wend
objTextFile.close
set objTextFile = nothing
else
oVisit.Common.logError err, "Just call me rubbish"
end if
set fsoObj = nothing
 
Aside from any other possible coding errors, ...

The .. tells the system to start looking 1 folder back from where your exe program is running. Try hard coding the complete path to your .txt file, and work from there.

Lemme know what U find. Good luck.

rossno@yahoo.com
 
I have now altered the script blocking and thats now gettingb past that stage. It then gets stuck on the getFile stage. It recognises that the file is there but seems to indicate that I have no permissions on the file?
I have checked these and it is set to everyone is that good enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top