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

problem when reading from a text file

Status
Not open for further replies.

matejv

Programmer
Jul 30, 2003
14
0
0
SI
Below is a script I use to read text from a file.
The problem is that it doesn't seem to work - when it comes to the "opentxtfile" part it just loads and loads and eventually times out. I'm running IIS on win2000.
Any ideas?

dim strFilePath
dim strFile
dim objFile
dim strFileTxt

strFilePath = "dir/" & rs("MyTxt")
strFile = server.mappath(strFilePath)
Set objFile = Server.Createobject("Scripting.FileSystemObject")

If objFile.fileexists(strFile) Then
Set strFileTxt = objFile.opentextfile(strFile)
While not strFileTxt.atendofstream
strFileTxt.readline
Wend
strFileTxt.close
End if
 
It's ok, I got it... Norton Antivirus Script Blocking.
 
1. Use Trim(rs("MyTxt")) instead of rs("MyTxt")

I Think this will help you.
I checked your code and it must work fine except the #(1) as i m not sure what field type are you using.

To see your code running . make a text file named "a.txt" in a subdirectory named "dir" (i used it as it is :) and write a few line in it , Don't forget to Press Enter at the end of each line) and then Run this Code from the root foler.


Code:
dim strFilePath
dim strFile
dim objFile
Dim strText
dim strFileTxt
dim strFileName

strFileName = "a.txt"

strFilePath = "dir/" &  strFileName

strFile = server.mappath(strFilePath)
Set objFile = Server.Createobject("Scripting.FileSystemObject")

If objFile.fileexists(strFile) Then
   Set strFileTxt = objFile.opentextfile(strFile)
    While not strFileTxt.atendofstream
     strText= strFileTxt.readline
     Response.Write strText & &quot;<br>&quot;
     Wend
   strFileTxt.close
   
End if





 
strFilePath = &quot;dir/&quot; & rs(&quot;MyTxt&quot;)
response.write strFilePath

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top