FSO操作示例(给初学者)(3)
filename1=request.Form("filename1")
if request.ServerVariables("PATH_TRANSLATED")<>filename then
set fso=server.CreateObject("scripting.filesystemobject")
set f1=fso.opentextfile(filename,2,true)
f1.write(content)
f1.close
if filename1<>"" and filename1<>filename then fso.deletefile(filename1)
tempurl=url&"?foldername="&fso.GetParentfoldername(filename)
set fso=nothing
end if
response.Redirect(tempurl)
end function
function filenew()
filename=request.QueryString("filename")
content=""
fileform filename,content,filename1
end function
function fileedit()
filename=request.QueryString("filename")
filename1=request.QueryString("filename")
set fso=server.CreateObject("scripting.filesystemobject")
set f1=fso.opentextfile(filename,1,true)
content=server.HTMLEncode(f1.readall)
f1.close
set fso=nothing
fileform filename,content,filename1
end function
function fileform(filename,content,filename1)
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="form1" method="post" action="<%= url%>?action=savefile">
<tr>
<td><input name="filename1" type="hidden" value="<%= filename1%>"><input name="filename" type="text" value="<%= filename%>" style="width:100%"></td>
</tr>
<tr>
<td><textarea name="content" wrap="VIRTUAL" style="width:100%;height:100%;font:Arial,Helvetica,sans-serif;" onKeyUp="style.height=this.scrollHeight;"><%= content%></textarea></td>
</tr>
<tr>
<td><center><input type="submit" name="Submit" value="保存" style="width:200"><input type="reset" name="Submit2" value="重置" style="width:200"></center></td>
</tr>
</form>
</table>
<%
end function
'文件夹操作函数
function delfolder()
foldername=request.QueryString("foldername")
set fso=server.CreateObject("scripting.filesystemobject")
tempurl=url&"?foldername="&fso.GetParentfoldername(foldername)
fso.deletefolder(foldername)
set fso=nothing
response.Redirect(tempurl)
end function
function savefolder()
foldername=request.Form("foldername")
foldername1=request.Form("foldername1")
set fso=server.CreateObject("scripting.filesystemobject")
if foldername1="" then
set f=fso.createfolder(foldername)
else
fso.MoveFolder foldername1,foldername
内容版权声明:除非注明,否则皆为本站原创文章。