请教ASP中如何读取.dat的文件?

来源:百度文库 编辑:神马文学网 时间:2024/04/28 19:08:19
以文本方式查看主题
-  我的帮助论坛(主要探讨 VFP 及其它编程技术)  (http://www.gz9f.com/bbs/index.asp)
--  CGI、ASP、JAVA论坛  (http://www.gz9f.com/bbs/list.asp?boardid=8)
----  请教ASP中如何读取.dat的文件?  (http://www.gz9f.com/bbs/dispbbs.asp?boardid=8&id=200853)
--  作者:pangcg
--  发布时间:2003-4-2 11:29:00
--  请教ASP中如何读取.dat的文件?
请教各位大虾,ASP中如何读取.dat的文件?
--  作者:初级VFP
--  发布时间:2003-4-2 22:44:00
--
<%
\‘以下为读取一行
Function file_Getword(filename)
Dim fileobj,thisfile
set fileobj=createobject("scripting.filesystemobject")
set thisfile=fileobj.opentextfile(updatefile,1,false)
file_Getword=thisfile.readline
thisfile.close
set fileobj=nothing
end function
response.write "文件内容:"&file_Getword(filename)
\‘以下为读取整个文件
dim fname,FS,FGetfile,Readfile,Cstr
fname="路径+文件"
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set FGetfile = FS.Getfile(fname)
Set Readfile = FGetfile.OpenAsTextStream(1,0)
Cstr=""
Do while Readfile.AtEndOfLine<>True
Cstr=Cstr&Readfile.ReadLine&chr(13)&chr(10)
Loop
Readfile.close
set FGetfile = nothing
set Readfile = nothing
Set FS = nothing
response.write Cstr
%>