FSO reading text files

Results 1 to 2 of 2

Thread: FSO reading text files

  1. #1
    Join Date
    Dec 1969

    Default FSO reading text files

    hello,<BR>I wsa wondering if there is a way to skip lines of a text file?<BR>LIke how to read into a line, but not read say just one line thats half way down the text file.<BR><BR>here&#039;s my code so far:<BR>&#060;%<BR>Dim objFSO<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>Dim objTextStream<BR><BR>const strFileName = "C: est.txt"<BR>const fsoForReading = 1<BR><BR>If objFSO.FileExists("C: est.txt") then<BR> &#039;The file exists, so open it and output its contents<BR> Set objTextStream = objFSO.OpenTextFile(strFileName, fsoForReading)<BR>objTextStream.Skip(1)<BR> Response.Write "&#060;PRE&#062;" & objTextStream.ReadAll & "&#060;/PRE&#062;"<BR> objTextStream.Close<BR> Set objTextStream = Nothing<BR>Else<BR> &#039;The file did not exist<BR> Response.Write strFileName & " was not found."<BR>End If<BR><BR>&#039;Clean up<BR>Set objFSO = Nothing<BR>%&#062;<BR><BR>any ideas?<BR><BR>thanks in advance for your time!

  2. #2
    Join Date
    Dec 1969

    Default RE: FSO reading text files

    You could read the file one line at a time with readline method:<BR><BR>http://www.elated.com/tutorials/programming/asp/filesystem_object/<BR>http://www.sloppycode.net/fso/?m=134<BR><BR>For more put "filesystem object readline" into google. <BR><BR>You also could use the code you have now and split it into an array to process it, split on vbcrlf. It may be faster to reading line by line but I&#039;m not positive. Either way you&#039;d need some way of determining what line you wanted to skip over be it by number (keep a count) or by contents of the line. Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts