Click to See Complete Forum and Search --> : opening file with asp... possible?
RoundCow
Jul 4th, 2000, 03:51 PM
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.
vbsquare
Jul 4th, 2000, 04:54 PM
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.
Hutty
Jul 6th, 2000, 03:10 PM
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.
capone
Jul 6th, 2000, 03:16 PM
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.
Hutty
Jul 6th, 2000, 03:19 PM
Thanks, i'm a newbie. I will play with it. The good part is that it can be done.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.