社区
ASP
帖子详情
如何用asp读文本文件。
guozhiw
2003-06-14 01:32:56
等待中。。。
...全文
57
9
打赏
收藏
如何用asp读文本文件。
等待中。。。
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Ngod
2003-06-14
打赏
举报
回复
method2
<% Option Explicit
Const Filename = "/readme.txt" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Create a filesystem object
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, _
TristateUseDefault)
' Read file in one hit
Dim Contents
Contents = TextStream.ReadAll
Response.write "<pre>" & Contents & "</pre><hr>"
TextStream.Close
Set TextStream = nothing
Else
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
End If
Set FSO = nothing
%>
Ngod
2003-06-14
打赏
举报
回复
method1
<% Option Explicit
Const Filename = "/readme.txt" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Create a filesystem object
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
' Get a handle to the file
Dim file
set file = FSO.GetFile(Filepath)
' Get some info about the file
Dim FileSize
FileSize = file.Size
Response.Write "<p><b>File: " & Filename & " (size " & FileSize &_
" bytes)</b></p><hr>"
Response.Write "<pre>"
' Open the file
Dim TextStream
Set TextStream = file.OpenAsTextStream(ForReading, _
TristateUseDefault)
' Read the file line by line
Do While Not TextStream.AtEndOfStream
Dim Line
Line = TextStream.readline
' Do something with "Line"
Line = Line & vbCRLF
Response.write Line
Loop
Response.Write "</pre><hr>"
Set TextStream = nothing
Else
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
End If
Set FSO = nothing
%>
fason
2003-06-14
打赏
举报
回复
http://www.aspsky.net/article/index.asp?classid=2&Nclassid=33
freezh
2003-06-14
打赏
举报
回复
WriteLine为写
readline为读
freezh
2003-06-14
打赏
举报
回复
这是一个读写的例 子
Sub ReadFiles
Dim fso, f1, ts, s
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
'' 写一行。
Response.Write "Writing file <br>"
f1.WriteLine "Hello World"
f1.WriteBlankLines(1)
f1.Close
'' 读取文件的内容。
Response.Write "Reading file <br>"
Set ts = fso.OpenTextFile("c:\testfile.txt", ForReading)
s = ts.ReadLine
Response.Write "File contents = ''" & s & "''"
ts.Close
End Sub
ddboy
2003-06-14
打赏
举报
回复
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(FileName, 1, False)
str = f.ReadAll
f.close
Set fso = Nothing
%>
fso其它方法或对象,参见VBScript帮助
freezh
2003-06-14
打赏
举报
回复
Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
叶子哟
2003-06-14
打赏
举报
回复
fso没问题!新建修改均可以
freezh
2003-06-14
打赏
举报
回复
使用fso
ASP
技术常遇问题解答-如何
读
取
文本文件
的内容?.zip
ASP
技术问题解答,希望对你有帮助。
ASP
读
写文件函数
利用AdoDb.Stream对象来
读
取UTF-8格式的
文本文件
利用AdoDb.Stream对象来写入UTF-8格式的
文本文件
无数据库
ASP
目录直
读
生成产品列表文本名称清单完美嵌入列表的程序
经典强悍的目录直
读
程序,做到无数据库输出产品列表,曾在铺中发表过一次,这次再次完善加入文本名称清单,嵌入产品列表,解决了老网站产品更新的大难题。我做网站维护一个人管理几百家客户,由于大部分老网站都是静态的,但是不乏一些客户同时要求更新几百张产品图片的情况,只有使用目录直
读
才能大大提高工作效率。 特色功能,就是支持分页图片下面的文字是
读
取的txt文件,非常不错的应用。
基于StreamRead和StreamWriter的使用(实例讲解)
如下所示: //StreamRead来
读
取一个文件 using (StreamReader sr = new StreamReader(@"C:\Users\enle\Desktop\新建文本文档.txt", Encoding.Default)) { while (!sr.EndOfStream)//循环的去
读
文件 { Console.WriteLine(sr.ReadLine()); } } Console.ReadKey(); StreamWriter写入一个
文本文件
//StreamWriter写入一个
文本文件
u
如何在
ASP
.NET C#, VB中
读
写
文本文件
描述:在处理
asp
.net 项目时,需要将一个文本框的内容写入位于应用程序根目录下的文件夹中的
文本文件
,然后从该
文本文件
中
读
取内容并插入另一个文本框。注意: 在上面的 WriteToFile 函数 ,如果
文本文件
不存在,StreamWriter 类将创建
文本文件
,如果存在,则覆盖该文件。注意:在应用程序的根目录中创建一个文件夹并将其命名为“TestFolder”。将在此文件夹中创建
文本文件
以写入和
读
取。
Asp
.Net C# 代码写入和
读
取
文本文件
。
Asp
.Net VB 代码写入和
读
取
文本文件
。
ASP
28,409
社区成员
356,971
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章