Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use FSO to display a text file in a three column format with headers in a web browser using ASP. How would I modify the sample code below to achieve this?
VB
Dim OpenFileobj, FSOobj,FilePath
FilePath=Server.MapPath("O.txt") 
Set FSOobj = Server.CreateObject("Scripting.FileSystemObject")


if FSOobj.fileExists(FilePath) Then
Set OpenFileobj = FSOobj.OpenTextFile(FilePath, 1)

Do While Not OpenFileobj.AtEndOfStream
Response.Write OpenFileobj.ReadLine & "<br>"
Loop

OpenFileobj.Close
Set OpenFileobj = Nothing
Else
Response.Write "File does not exist"
End if
Set FSOobj = Nothing

Thanks
Posted
Updated 29-Jul-10 5:05am
v3

Just to clarify, this is classic ASP, right?

You should start by removing the <br></br> tag and re-organizing a little bit so that you're not reading from the file and writing to the response stream in the same statement.

1) Add a Response.Write("<table>") before reading the lines
2) Add a Response.Write("<tr>") before each line
3) Split the string you've read (what is your delimiter?)
4) Add a <td> tag around each of the three elements in the line
5) Close your <tr> tag
6) After all lines are read, add a Response.Write("</table>") to close out the table

If you are in ASP.NET there are much more elegant ways to do this.

Cheers.
 
Share this answer
 
v4
Comments
TheyCallMeMrJames 29-Jul-10 11:50am    
geez that was an effort to escape properly!
Thanks for the quick reply. I will give this a shot.
 
Share this answer
 
Comments
Arun Jacob 30-Jul-10 8:36am    
Reason for my vote of 1
Add this as comment, not as answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900