显示文本文件的数据 [英] Display data of text file
本文介绍了显示文本文件的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用FSO在使用ASP的Web浏览器中以三列格式显示带有标题的文本文件.我将如何修改下面的示例代码来实现这一目标?
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?
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
感谢
推荐答案
请澄清一下,这是经典的ASP,对吗?
您应该先删除<br></br>
标记并重新组织一下,以免您从文件中读取并在同一条语句中写入响应流.
1)阅读行之前添加Response.Write("<table>")
2)在每行之前添加Response.Write("<tr>")
3)拆分您已阅读的字符串(什么是分隔符?)
4)在该行的三个元素的每个周围添加一个<td>
标记
5)关闭您的<tr>
标签
6)读取所有行后,添加Response.Write(</table>")以关闭表
如果您使用的是ASP.NET,则可以使用更优雅的方法.
干杯.
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 aResponse.Write("<table>")
before reading the lines
2) Add aResponse.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.
感谢您的快速回复.我会试一试.
Thanks for the quick reply. I will give this a shot.
这篇关于显示文本文件的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文