欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何做一个文本书写器?

程序员文章站 2022-05-03 15:32:28
<%function writetofile(filename, contents, append)on...

<%
function writetofile(filename, contents, append)
on error resume next

if append = true then
  imode = 8
else
  imode = 2
end if
set ofs = server.createobject("scripting.filesystemobject")
set otextfile = ofs.opentextfile(filename, imode, true)
otextfile.write contents
otextfile.close
set otextfile = nothing
set ofs = nothing

end function

%>

<html>
<body>

<%
writetofile "c:\intels\test1.txt", "
中国水利水电出版社(www.waterpub.com.cn)——全国优秀出版社", true
writetofile "c:\intels\test2.txt", "
中国水利水电出版社(www.waterpub.com.cn)——全国优秀出版社", false
writetofile "c:\intels\test1.txt", chr(13) & chr(10) & "
随风起舞(www.intels.net)——时尚咨询的个人网站", true
writetofile "c:\intels\test2.txt", chr(13) & chr(10) & "
随风起舞(www.intels.net)——时尚咨询的个人网站", false

'test1.txt contains:
'
中国水利水电出版社(www.waterpub.com.cn)——全国优秀出版社
'
随风起舞(www.intels.net)——时尚咨询的个人网站

'test2.text contains:
'
随风起舞(www.intels.net)——时尚咨询的个人网站
%>
write to file test is complete
</body></html>