<% Function ShowCode(filename) Set fso = Server.CreateObject("Scripting.FileSystemObject") Set cnrs = fso.OpenTextFile(filename, 1) While Not cnrs.AtEndOfStream rsline = cnrs.ReadLine rsline = server.HTMLEncode(rsline) Response.Write(rsline & "<br>") Wend end Function %> <form action="viewcode.asp" method="post"> 输入文件名<input type="file" name="filename"> <input type="submit" value="查看源程序"> </form> <% file=request.form("filename") response.write (file & "源程序如下<hr>") If trim(file)<> "" then Call ShowCode(file) End If %> |
<% whichfile=server.mappath("test.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set txt = fso.OpenTextFile(whichfile,1) rline = txt.ReadAll rline=replace(Server.HtmlEncode(rline),Chr(13),"<br>") Response.Write rline txt.Close %> |
<% If not request.Form("NextLine")="" then Set fso=Server.CreateObject("Scripting.FileSystemobject") textfile1=Server.MapPath("story.txt") set cnrs=fso.OpenTextFile(textfile1,8) cnrs.WriteLine(Request.Form("NextLine")) cnrs.Close end if %> 故事如下: <% Set fso=Server.CreateObject("Scripting.FileSystemObject") textfile1=Server.MapPath("story.txt") set cnrs=fso.OpenTextFile(textfile1,1) while not cnrs.AtEndOfStream Response.Write " " & cnrs.ReadLine wend cnrs.close %> <hr> <form method="post" action="story.asp"> 请输入这个故事的新行:<input name="NextLine" type="text" size="70"> <input type="submit" value="提交"> </form> 学习交流
热门图片
猜你喜欢的新闻
新闻热点 2024-04-27 13:35:46
2024-04-27 13:33:47
2024-04-24 22:53:44
2024-04-23 19:32:50
2024-04-23 19:25:50
2024-04-23 19:13:19
疑难解答 |