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.
Printable View
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.
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.
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.
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.
Thanks, i'm a newbie. I will play with it. The good part is that it can be done.