asp读写文件示例
asp读出文件放入表单的textarea容器中,修改后写回原文件中。注意如果文件编码不是系统默认的ansi,调用opentextfile方法时加上编码。
参考
-
Scripting.FileSystemObject的
OpenTextFile
方法参数说明 - asp检测文件编码
asp读写文件示例源代码
<% set fso=server.CreateObject("scripting.filesystemobject") if request.querystring("action")="update" then content=request.Form("content") set ts=fso.OpenTextFile(server.MapPath("1.txt"),2) ts.write content ts.close set ts=nothing else set ts=fso.OpenTextFile(server.MapPath("1.txt")) content=ts.readall ts.close set ts=nothing end if set fso=nothing %> <form method="post" action="read.asp?action=update"> <textarea rows="10" cols="60" name="content"><%=content %></textarea><br /> <input type="submit" value="修改" /> </form>
加支付宝好友偷能量挖...
原创文章,转载请注明出处:asp读写文件示例