Results 1 to 3 of 3

Thread: Reading a text file using the File System Object

  1. #1
    matthewralston
    Guest

    Reading a text file using the File System Object

    Has anyone got a quick bit of code for reading the contents of a text file into a variable using the file system object?

    From past experience with the fso I know I'd be able to figure it out but it's do damn fiddly that I can't be bothered if someone's already done it.

    Anyone got a bit of code they can paste in for me? Don't worry if you ain't...I'll just have to do it myself the old fashioned way!

    Ta,

  2. #2
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    Code:
    dim filesys, txtfile, line
    set filesys = CreateObject("Scripting.FileSystemObject")
    set txtfile = filesys.OpenTextFile("c:\file.txt",1,0)
    Do
       line = txtfile.ReadLine
    Loop Until txtfile.AtEndOfStream
    txtfile.close
    This should be working. It might be Server.CreateObject... but you'll notice.

  3. #3
    matthewralston
    Guest

    Thank you very much...

    That should do me just fine... I was expecting it to involve creating more fso objects for that.. one for the folder...one for the file...one as a text stream...

    I'll be putting it on an ASP page so I will be using Server.CreateObject .

Posting Permissions

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



Click Here to Expand Forum to Full Width