日期:2014-05-17  浏览次数:20754 次

如何获得文本文件中的数据
如题目.具体问题在
http://community.csdn.net/Expert/topic/5332/5332437.xml?temp=.2313806
怎么没人帮忙呢.帮忙的话.两边帖子我都加分哦.谢谢

------解决方案--------------------
一般都用FSO来解决个 这个是最基本的 特别是在采集中 文本地址批量入库的时候可以用到
------解决方案--------------------
先把文本上传的相关目录,然后fso读取文本里的数据
下面是逐行读取数据的,然后再split分隔
Server.ScriptTimeOut=500

'连接数据库代码省略

Const ForReading = 1
Set fso = Server.CreateObject( "Scripting.FileSystemObject ")
' 读取文件的内容,假设内容放在D:\myText.txt,。
Set ts = fso.OpenTextFile(Server.MapPath( "/kkk.txt "), ForReading)
Do while not ts.AtEndOfStream
s = ts.ReadLine '逐行读取txt文件的内容
Response.Write s

s=split(s, "$ ",-1,1)
response.write s(3)

loop
ts.Close


------解决方案--------------------
<%

Dim fsoObject '文件系统对象
Dim tsObject
Dim filObject
Dim lngVisitorNumber
Dim txt
lngVisitorNumber = 0
Set fsoObject = Server.CreateObject( "Scripting.FileSystemObject ")
Set filObject = fsoObject.GetFile(Server.MapPath( "文本文件.txt "))
Set tsObject = filObject.OpenAsTextStream
txt=tsObject.ReadAll
%>
<%=txt%>