<%@ LANGUAGE="VBScript" %>
<% 'Set file i/o constants.
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
filename = "test.txt"
path = Server.MapPath("data") & "\" & filename
' 映射文件名到服务器的物理路径.
operation = Request.Form("operation") %>
' 得到请求操作.
<html>
<head>
<title>千花飞舞之处理文件</title>
</head>
<body>
<font face="Arial,Helvetica" size=2>
<table bgcolor="#000000" border=0 cellpadding=1 cellspacing=0><tr><td>
<table bgcolor="#008080" border=0 cellpadding=8 cellspacing=0><tr valign=bottom><td>
<font face="Arial,Helvetica" size=2>
<form action="<% = Request.ServerVariables("script_NAME") %>" method="post">
<input name="operation" type="radio" value="create"> 创建
<input name="operation" type="radio" value="delete"> 删除
<input name="operation" type="radio" value="read" checked> 读取
<input name="operation" type="radio" value="write"> 写入
<input name="operation" type="radio" value="append"> 添加
<p>
<center>
<input type="submit" value="确定"> <input type="reset" value="重置">
</center>
</form>
<p>
<a href="fileops.html"><b>返回</b></a>
</font>
</td></tr></table>
</td></tr></table>
<p>
<%
if operation = "create" then
call CreateFile(path)
call ReadFile(path)
elseif operation = "delete" then
call DeleteFile(path)
elseif operation = "read" then
call ReadFile(path)
elseif operation = "write" then
call WriteFile(path)
call ReadFile(path)
elseif operation = "append" then
call AppendFile(path)
call ReadFile(path)
end if
' 执行请求操作.
%>
<p>
</font>
</body></html>
<% sub CreateFile(path)
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
if fs.FileExists(path) then
Response.Write(<b>噢,文件" & filename & " 已经存在,创建失败!</b><br>" & vbCrLf)
' 如果文件早已存在则显示一个错误信息
else
Response.Write(恭喜, " & filename & "创建成功!<br>" & vbCrLf)
' 否则创建它并写入数据
set file = fs.CreateTextFile(path)
Response.Write(向" & filename & "写入数据...<br>" & vbCrLf)
file.WriteLine("Line 1 added " & Now() & ".")
file.WriteLine("Line 2 added " & Now() & ".")
file.WriteLine("Line 3 added " & Now() & ".")
file.WriteLine("Line 4 added " & Now() & ".")
file.WriteLine("Line 5 added " & Now() & ".")
file.Close()
end if
end sub
sub DeleteFile(path)
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
if not fs.FileExists(path) then
' 如果文件不存在则显示一个错误信息.
Response.Write(<b>噢,文件" & filename & "不存在,您删除什么!</b><br>" & vbCrLf)
else
Response.Write(恭喜," & filename & "删除成功!<br>" & vbCrLf)
' 否则删除它.
fs.DeleteFile(path)
end if
end sub
sub ReadFile(path)
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
if not fs.FileExists(path) then
Response.Write(<b>噢,文件" & filename & "不存在,您读取什么!</b><br>" & vbCrLf)
' 如果文件不存在则显示一个错误信息.
else
set file = fs.OpenTextFile(path, ForReading)
Response.Write(恭喜," & filename & "读取成功!" & vbCrLf)
' 否则打开它并显示内容.
Response.Write("<p>" & vbCrLf)
Response.Write("<hr size=1>" & vbCrLf)
Response.Write("<font size=3><pre>" & vbCrLf)
do while not file.AtEndOfStream
Response.Write(file.ReadLine & vbCrLf)
loop
Response.Write("</pre></font>" & vbCrLf)
Response.Write("<hr size=1>" & vbCrLf)
file.Close()
end if
end sub
sub WriteFile(path)
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
if not fs.FileExists(path) then
Response.Write(<b>噢,文件" & filename & "不存在,您写入什么!</b><br>" & vbCrLf)
' 如果文件不存在则显示一个错误信息.
else
set file = fs.OpenTextFile(path, ForWriting)
' 否则,改写内容.
Response.Write(Rewriting file " & filename & ".<br>" & vbCrLf)
file.WriteLine("Rewritting file with line 1 added " & Now() & ".")
file.WriteLine("Rewritting file with line 2 added " & Now() & ".")
file.WriteLine("Rewritting file with line 3 added " & Now() & ".")
file.Close()
end if
end sub
sub AppendFile(path)
dim fs, file
set fs = CreateObject("Scripting.FileSystemObject")
if fs.FileExists(path) then
set file = fs.GetFile(path)
if file.size > 500 then
' 如果文件存在,检查它的大小并退出,如果它超过500K.
Response.Write(<b>噢,文件" & filename & "超过了大小限制, 添加失败!</b><br>" &
vbCrLf)
exit sub
end if
else
Response.Write(噢,文件" & filename & "不存在!但它将会被创建...<br>" & vbCrLf)
end if
' 如果文件不存在,显示一个提示信息.
Response.Write(添加内容到文件" & filename & "...<br>" & vbCrLf)
set file = fs.OpenTextFile(path, ForAppending, true)
file.WriteLine("添加的新内容:" & Now() & ".")
' 当需要给它添加新内容时打开或创建文件
file.Close()
end sub %>
[1]
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]