📄 4-11.asp
字号:
<html>
<head>
<title>创建、添加、追加、读取文件数据</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
whichFN=Server.Mappath ("1.txt")
Set fstemp = server.CreateObject("Scripting.FileSystemObject")
Set filetemp = fstemp.CreateTextFile(whichFN, true)
' true =表示如果文件已经存在,能被改写
' false =表示不能被改写
filetemp.WriteLine("已经新建一个文件!!!!")
'输入三个空行
filetemp.writeblanklines(3)
filetemp.WriteLine("学好ASP,走遍天下都不怕!")
filetemp.Close '关闭文件
' 现在追加入一些数据
forappending =8
'在这里可以利用一个变量forappending =8
set filetemp=fstemp.OpentextFile(whichFN, forappending)
filetemp.writeline "你好,我是新来的!"
filetemp.writeline "我也是新来的..."
filetemp.close
'读取文件数据
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichFN, 1, False)
counter=0
do while not thisfile.AtEndOfStream
counter=counter+1
thisline=thisfile.readline
response.write thisline & "<br>"
loop
thisfile.Close
set thisfile=nothing
set fs=nothing
set filetemp=nothing
set fstemp=nothing
%>
</head>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -