< html>
< body>
< form action=”manage.asp” method=”post”>
< input type=”text” size=”10″ name=”username”>
< input type=”text” size=”10″ name=”homepage”>
< input type=”text” size=”10″ name=”Email”>
< /form>
< /body>
< /html>
 xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /??
manage.asp
< %
strName = Request.Form(“username”)
strHomePage = Request.Form(“homepage”)
strEmail = Request.Form(“Email”)
‘ è·å表åä¿¡æ¯.
Â
Set fso = Server.CreateObject(“Scripting.FileSystemObject”)
‘ å建fso对象.
Â
path = “c:chunfeng/form.txt”
ForReading = 1, ForWriting = 2, ForAppending = 3
Â
set file = fso.opentextfile(path, ForAppending, trUE)
‘ æå¼æ件. OpenTextFileæ¹æ³å°è¿åä¸ä¸ªTextStream对象, è¿ä¸ªå¯¹è±¡æ示äºæä½æ件å 容çæ¹æ³,å¦åã读ä¸è¡ãè·³è¿ä¸è¡.å¦æ们è¿å¨OpentextFileçå½ä»¤åæ°ä¸å®ä¹äºtrUE,æ为å¦æ件ä¸åå¨,å°±å建å®.å 为å¦ææ件ä¸åå¨,ä¸æ²¡å®ä¹trUEåæ°,ç³»ç»å°±ä¼åºé.
Â
file.write(strName) & vbcrlf
‘ VB常évbcrlf产çä¸ä¸ªæ¢è¡ç¬¦.
file.write(strHomePage) & vbcrlf
file.write(strEmail) & vbcrlf
‘ åæ件åä¿¡æ¯.
Â
file.close
set file = nothing
set fso = nothing
‘ æ¸ ç©º.
Â
ç°å¨æå¼form.txtï¼å¯ä»¥çå°å¦ä¸çä¿¡æ¯ï¼
User’s name
User’s home page
User’s email
ãã
æ们åææ¯ä¸åæ¥è®¿è
çä¿¡æ¯ä»è®°å½ä¸å离åºæ¥ãå 为å®æ²¡æ象æ°æ®åºä¸æ ·çåï¼æ以è¦æ³åæ³ä»åæè®°å½çæ件ä¸è¯»åºãå¨æå建çæ件ä¸ï¼ç¬¬1è¡æ¯ç¨æ·åï¼ç¬¬2è¡æ¯ç¨æ·ä¸»é¡µï¼ç¬¬3è¡æ¯ç¨æ·çµåä¿¡ç®±ï¼å
¶ä»ç¨æ·çä¿¡æ¯ä¹æ¯è¿æ ·æåï¼å³æ¯3è¡å
å«ä¸ä¸ªç¨æ·ä¿¡æ¯ãè¿æ ·ï¼æ们就å¯ä»¥åå©ç¨FSOæ¥è¯»åäºï¼
< %
set fso = Server.Createobject(“Scripting.FileSystemObject”)
‘ å建fso对象.
path = “c:chunfeng/form.txt”
set file = fso.opentextfile(path, 1)
‘ æå¼æ件.
do until file.AtEndOfStream
‘ AtEndOfStreamæ¯TextStream对象çå±æ§,å®æ示ä½æ¶å°æ件尾é¨.
    Response.write(“Name: ” & file.ReadLine & ” “)
‘ ReadLineæ¹æ³è¯»å1è¡å
容,ç´å°éå°æ¢è¡ç¬¦,éåçReadLineè°ç¨è¯»åä¸ä¸è¡.
    Response.write(“Home Page: ” & file.ReadLine & ” “)
    Response.write(“Email: ” & file.ReadLine & “< p>”)
‘ éè¡åæå¹¶æ ¼å¼åæ°æ®.
loop
‘ 循ç¯ååºæ¯ä¸ç¨æ·çä¿¡æ¯.
file.close
set file = nothing
set fso = nothing
%>
é½å好äºã
å¦æform.txtæ¬èº«æ°æ®åºç°å·®éï¼å¦æ¯ä¸ç¨æ·ä¿¡æ¯åªæ2è¡èä¸æ¯3è¡ï¼é£ä¹å°±ä¼äº§çå¦ä¸é误信æ¯ï¼
ãã Server object error ‘ASP 0177 : 800a003e’
[1]