FILESYSTEMOBJECT组件
类别: ASP教程
该组件是负责启动文件或目录的管理,如果你象读取文件的内容,你必须配合Textstream一起用。它提供了Createtextfile, openTextFile,GetFile,GetFileName等函数。下面是一个实例:如何利用ASP在一个以有文件中添加内容
例子
<!-- Story.asp -->
<%
IF NOT Request.Form("NextLine")="" THEN
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile("d:story.txt", 8, TRUE)
MyTextFile.WriteLine(Request.Form("NextLine"))
MyTextFile.Close
END IF
%>
<HTML>
<HEAD><TITLE> Online Story </TITLE></HEAD>
<BODY>
<HR>
<%
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile("d:story.txt")
WHILE NOT MyTextFile.AtEndOfStream
Response.Write(" "&MyTextFile.ReadLine)
WEND
MyTextFile.Close
%>
<HR>
<H3>Enter a new line for the story: </H3>
<FORM METHOD="POST" ACTION="story.asp">
<INPUT NAME="NextLine" TYPE="TEXT" SIZE=70 maxlength="100">
<INPUT TYPE="SUBMIT" VALUE="Submit Sentence">
</FORM>
</BODY>
</HTML>
例子
<!-- Story.asp -->
<%
IF NOT Request.Form("NextLine")="" THEN
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile("d:story.txt", 8, TRUE)
MyTextFile.WriteLine(Request.Form("NextLine"))
MyTextFile.Close
END IF
%>
<HTML>
<HEAD><TITLE> Online Story </TITLE></HEAD>
<BODY>
<HR>
<%
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile("d:story.txt")
WHILE NOT MyTextFile.AtEndOfStream
Response.Write(" "&MyTextFile.ReadLine)
WEND
MyTextFile.Close
%>
<HR>
<H3>Enter a new line for the story: </H3>
<FORM METHOD="POST" ACTION="story.asp">
<INPUT NAME="NextLine" TYPE="TEXT" SIZE=70 maxlength="100">
<INPUT TYPE="SUBMIT" VALUE="Submit Sentence">
</FORM>
</BODY>
</HTML>
- 上一篇: CHART组件在ASP中的应用
- 下一篇: 几个比较好用的ASP检查函数
-= 资 源 教 程 =-
文 章 搜 索