Results 1 to 5 of 5

Thread: opening file with asp... possible?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 1999
    Posts
    24

    Angry

    yea i am new to asp... but i was wondering if i could make a text file or something filled with html code, and have the ASP file read it line by line and write it and display it... or do i have to make a database, cause i am too lazy for that.

  2. #2
    Addicted Member
    Join Date
    Jan 1999
    Posts
    173
    Hi,
    To make a text file use this code:

    <%
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
    Set File = FSO.CreateTextFile("pathtofile.txt")
    File.Save
    %>

    To read a file line by line use:

    <%
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
    Set File = FSO.OpenTextFile("pathtofile.txt")

    Do While Not File.AtEndOfStream
    sLine = File.ReadLine
    Response.Write sLine
    Loop
    %>

    If you want more examples just let me know.
    "To the glory of God!"


  3. #3
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Reading a text file

    VBsquare, how would u read a text file /ascii file like a database? Parsing the comma delimited format so that u get the results in a table format? thanks.

  4. #4
    Member
    Join Date
    Jun 2000
    Posts
    45
    You can use the Split function to break it into an array of strings:
    strFile = Split(strFile, ",")
    Then put each new string into the table
    counter = ubound(strFile)
    For count = 0 To counter
    Response.Write "<TD>" & strFile(count) & "</TD>"
    Next

    At least that's basincally how I trundled through it.

  5. #5
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Reading Text File

    Thanks, i'm a newbie. I will play with it. The good part is that it can be done.

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