如何在经典asp中读取文本文件 [英] How to read text file in classic asp
本文介绍了如何在经典asp中读取文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在上传图片.在上传图片时,我将图片名称和该 iage 的链接保存在一个文本文件中.像这样,abc.jpeg,http://google.com
I am uploading image.While uploading images i am saving image name and the link for that iage in one textfile. like this, abc.jpeg,http://google.com
现在我想使用经典的 asp 显示所有带有相应链接的图像.
Now i want to display all that images with corresponding links using classic asp.
我应该怎么做?
请帮忙.
我使用了这个 asp 代码:
I used this asp code:
<%
For Each FileName in fold.Files
Dim Fname
Dim strFileName
Dim objFSO
Dim objTextFile
Dim URLString
Dim strReadLineText
Fname= mid(FileName.Path,instrrev(FileName.Path,"\")+1)
strFileName = "../admin/Links.txt"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(strFileName))
URLString=""
Do While Not objTextFile.AtEndOfStream
strReadLineText = objTextFile.ReadLine
'response.Write(strReadLineText & "<br>")
If strReadLineText<>"" then
If Instr(strReadLineText,",")>0 then
strReadLineTextArr=split(strReadLineText,",")
response.Write(strReadLineTextArr(0))
URLString=strReadLineTextArr(1)
end if
end if
Loop
' Close and release file references
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
它显示所有图像,但所有图像的链接是相同的.它直接从文本文件中读取最后一个链接......我的代码有什么问题?
its displaying all images but for all images link is same.its reading directly the last link from textfile....What is the problem with my code?
推荐答案
你可以试试这样的 -
Dim lineData
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.OpenTextFile(Server.MapPath("imagedata.txt"), 1, true)
Do Until fs.AtEndOfStream
lineData = fs.ReadLine
'do some parsing on lineData to get image data
'output parsed data to screen
Response.Write lineData
Loop
fs.close: set fs = nothing
这篇关于如何在经典asp中读取文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文