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

FSO操作示例(给初学者)

程序员文章站 2022-07-02 07:53:43
把下面代码存到一个asp文件中即可,方便管理服务器上的文件 http://bbs.asp2004.net 制作:小灰 qq:103895<...</div> <div class="content"> 把下面代码存到一个asp文件中即可,方便管理服务器上的文件 <br><title>http://bbs.asp2004.net 制作:小灰 qq:103895</title> <br><meta http-equiv="content-type" content="text/html; charset=gb2312"> <br><style type="text/css"> <br><!-- <br>a:link { <br> font-size: 9pt; <br>} <br>a:visited { <br> font-size: 9pt; <br>} <br>a:hover { <br> font-size: 9pt; <br>} <br>a:active { <br> font-size: 9pt; <br>} <br>body { <br> font-size: 9pt; <br> margin-left: 0px; <br> margin-top: 0px; <br> margin-right: 0px; <br> margin-bottom: 0px; <br> line-height: 20px; <br>} <br>td { <br> font-size: 9pt; <br> line-height: 20px; <br>} <br>--> <br></style> <br><% <br>action=request.querystring("action") <br>temp=split(request.servervariables("url"),"/") <br>url=temp(ubound(temp)) <br>chklogin() <br>select case action <br>case "logout" <br> logout() <br>case "delfile" <br> delfile() <br>case "savefile" <br> savefile() <br>case "editfile" <br> fileedit() <br>case "newfile" <br> filenew() <br>case "upload" <br> upload() <br>case "saveupload" <br> saveupload() <br>case "delfolder" <br> delfolder() <br>case "savefolder" <br> savefolder() <br>case "editfolder" <br> editfolder() <br>case "newfolder" <br> newfolder() <br>case else <br> foldername=request.querystring("foldername") <br> filename=request.querystring("filename") <br> path=foldername <br> if path="" then path=server.mappath("./") <br> showfolderlist(path) <br>end select <br><br>function showfolderlist(folderspec) <br>temp=request.servervariables("http_referer") <br>temp=left(temp,instrrev(temp,"/")) <br>temp1=len(folderspec)-len(server.mappath("./"))-1 <br>if temp1>0 then <br> temp1=right(folderspec,cint(temp1)) <br>elseif temp1=-1 then <br> temp1="" <br>end if <br>tempurl=temp+replace(temp1,"\","/")+"/" <br>set fso = createobject("scripting.filesystemobject") <br>upfolderspec=fso.getparentfoldername(folderspec&"\") <br>%> <br><a href="<%= url%>?action=newfolder&foldername=<%= folderspec%>">新建文件夹</a> | <a href="<%= url%>?action=newfile&filename=<%= folderspec&"\"%>">新建文件</a> | <a href="<%= url%>?action=upload">上传文件</a> | <a href="<%= url%>?foldername=<%= upfolderspec%>">向上</a> | <a href="file.asp">返回首页</a> | <a href="<%= url%>?action=logout">退出</a> <br><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#6595d6"> <br> <tr bgcolor="#e4e8ef"> <br> <td width="64%"><div align="center">名称</div></td> <br> <td width="7%"><div align="right">大小</div></td> <br> <td width="6%"><div align="center">类型</div></td> <br> <td width="15%"><div align="left">修改时间</div></td> <br> <td width="8%"><div align="center">操作</div></td> <br> </tr> <br><% <br>'列出目录 <br>set f = fso.getfolder(folderspec) <br>set fc = f.subfolders <br>for each f1 in fc <br>%> <br> <tr bgcolor="#e4e8ef" onmouseout=this.bgcolor='#e4e8ef'; onmouseover=this.bgcolor='#ffffff';> <br> <td><a href="<%= url%>?foldername=<%= folderspec%>\<%= f1.name%>"><%= f1.name%></a></td> <br> <td><div align="right"><%= f1.size%></div></td> <br> <td><div align="center">文件夹</div></td> <br> <td><div align="left"><%= f1.datelastmodified%></div></td> <br> <td><a href="<%= url%>?action=editfolder&foldername=<%= folderspec&"\"&f1.name%>">修改</a> <a href="<%= url%>?action=delfolder&foldername=<%= folderspec&"\"&f1.name%>" onclick="{if(confirm('删除文件夹<<%= f1.name%>>么?')){return true;}return false;}">删除</a></td> <br> </tr> <br><% <br>next <br>'列出文件 <br>set fc = f.files <br>for each f1 in fc <br>%> <br> <tr bgcolor="#e4e8ef" onmouseout=this.bgcolor='#e4e8ef'; onmouseover=this.bgcolor='#ffffff';> <br> <td><a href="<%= tempurl+f1.name%>" target="_blank"><%= f1.name%></a></td> <br> <td><div align="right"><%= f1.size%></div></td> <br> <td><div align="left"></div></td> <br> <td><div align="left"><%= f1.datelastmodified%></div></td> <br> <td><a href="<%= url%>?action=editfile&filename=<%= folderspec&"\"&f1.name%>">修改</a> <a href="<%= url%>?action=delfile&filename=<%= folderspec&"\"&f1.name%>" onclick="{if(confirm('删除文件<<%= f1.name%>>么?')){return true;}return false;}">删除</a></td> <br> </tr> <br><% <br>next <br>set fso=nothing <br>%> <br></table> <br><% <br>end function <br>'文件操作 <br>function delfile() <br> filename=request.querystring("filename") <br> set fso=server.createobject("scripting.filesystemobject") <br> fso.deletefile(filename) <br> tempurl=url&"?foldername="&fso.getparentfoldername(filename) <br> set fso=nothing <br> response.redirect(tempurl) <br>end function <br><br>function savefile() <br> filename=request.form("filename") <br> content=request.form("content") <br> filename1=request.form("filename1") <br> if request.servervariables("path_translated")<>filename then <br> set fso=server.createobject("scripting.filesystemobject") <br> set f1=fso.opentextfile(filename,2,true) <br> f1.write(content) <br> f1.close <br> if filename1<>"" and filename1<>filename then fso.deletefile(filename1) <br> tempurl=url&"?foldername="&fso.getparentfoldername(filename) <br> set fso=nothing <br> end if <br> response.redirect(tempurl) <br>end function <br><br>function filenew() <br> filename=request.querystring("filename") <br> content="" <br> fileform filename,content,filename1 <br>end function <br><br>function fileedit() <br> filename=request.querystring("filename") <br> filename1=request.querystring("filename") <br> set fso=server.createobject("scripting.filesystemobject") <br> set f1=fso.opentextfile(filename,1,true) <br> content=server.htmlencode(f1.readall) <br> f1.close <br> set fso=nothing <br> fileform filename,content,filename1 <br>end function <br><br>function fileform(filename,content,filename1) <br>%> <br> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <br><form name="form1" method="post" action="<%= url%>?action=savefile"> <br> <tr> <br> <td><input name="filename1" type="hidden" value="<%= filename1%>"><input name="filename" type="text" value="<%= filename%>" style="width:100%"></td> <br> </tr> <br> <tr> <br> <td><textarea name="content" wrap="virtual" style="width:100%;height:100%;font:arial,helvetica,sans-serif;" onkeyup="style.height=this.scrollheight;"><%= content%></textarea></td> <br> </tr> <br> <tr> <br> <td><center><input type="submit" name="submit" value="保存" style="width:200"><input type="reset" name="submit2" value="重置" style="width:200"></center></td> <br> </tr> <br></form> <br></table> <br><% <br>end function <br>'文件夹操作函数 <br>function delfolder() <br> foldername=request.querystring("foldername") <br> set fso=server.createobject("scripting.filesystemobject") <br> tempurl=url&"?foldername="&fso.getparentfoldername(foldername) <br> fso.deletefolder(foldername) <br> set fso=nothing <br> response.redirect(tempurl) <br>end function <br><br>function savefolder() <br> foldername=request.form("foldername") <br> foldername1=request.form("foldername1") <br> set fso=server.createobject("scripting.filesystemobject") <br> if foldername1="" then <br> set f=fso.createfolder(foldername) <br> else <br> fso.movefolder foldername1,foldername <br> end if <br> tempurl=url&"?foldername="&f <br> set fso=nothing <br> response.redirect(tempurl) <br>end function <br><br>function newfolder() <br> foldername=request.querystring("foldername")&"\" <br> formfolder foldername,foldername1 <br>end function <br><br>function editfolder() <br> foldername=request.querystring("foldername") <br> foldername1=request.querystring("foldername") <br> formfolder foldername,foldername1 <br>end function <br><br>function formfolder(foldername,foldername1) <br>%> <br> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <br><form name="form1" method="post" action="<%= url%>?action=savefolder"> <br> <tr><td><input name="foldername1" type="hidden" value="<%= foldername1%>"><input name="foldername" type="text" value="<%= foldername%>" style="width:100%"></td></tr> <br> <tr><td><center><input type="submit" name="submit" value="保存" style="width:200"><input type="reset" name="submit2" value="重置" style="width:200"></center></td></tr> <br></form> <br> </table> <br><% <br>end function <br><br>function upload() <br>%> <br><form action="file.asp?action=saveupload" method="post" enctype="multipart/form-data" name="form2"> <br> <div align="center">有待完成 <br> <input type="file" name="file" style="width:80%"> <br> <input type="submit" name="submit" value="提交"> <br> </div> <br></form> <br><% <br>end function <br><br>function saveupload() <br>'有待实现 <br>end function <br><br>'登陆 <br>function chklogin() <br>password=request.form("password") <br>if password="ok" then session("login")="login" <br>if session("login")<>"login" then login <br>end function <br><br>function login() <br>%> <br><form name="form1" method="post" action="<%= url%>?action=chklogin"> <br><center>请输入密码:<input name="password" type="password"><input type="submit" name="submit" value="登陆"></center> <br></form> <br><% <br>response.end() <br>end function <br><br>function logout() <br>session.abandon() <br>response.redirect(url) <br>end function <br>%> <br><p> </p> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/1605223.html"> 多域名绑定到一个空间访问不同首页的技巧 </a> </p> <p> 下一篇: <a href="/article/1605225.html"> Go语言数据类型 </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/2112194.html" target="_blank" title="Flask框架实现给视图函数增加装饰器操作示例"> <h2> Flask框架实现给视图函数增加装饰器操作示例 </h2> </a> </li> <li> <a href="/article/1605224.html" target="_blank" title="FSO操作示例(给初学者)"> <h2> FSO操作示例(给初学者) </h2> </a> </li> <li> <a href="/article/1517783.html" target="_blank" title="VUE 实现动态给对象增加属性,并触发视图更新操作示例"> <h2> VUE 实现动态给对象增加属性,并触发视图更新操作示例 </h2> </a> </li> <li> <a href="/article/1358483.html" target="_blank" title="适合初学者的MySQL学习笔记之表操作示例"> <h2> 适合初学者的MySQL学习笔记之表操作示例 </h2> </a> </li> <li> <a href="/article/1318323.html" target="_blank" title="Flask框架实现给视图函数增加装饰器操作示例"> <h2> Flask框架实现给视图函数增加装饰器操作示例 </h2> </a> </li> <li> <a href="/article/870286.html" target="_blank" title="zend studio10.6.2不会建立web service,哪位高手给一个示例或操作步骤"> <h2> zend studio10.6.2不会建立web service,哪位高手给一个示例或操作步骤 </h2> </a> </li> <li> <a href="/article/838558.html" target="_blank" title="FSO操作示例(给初学者)"> <h2> FSO操作示例(给初学者) </h2> </a> </li> <li> <a href="/article/626038.html" target="_blank" title="js操作label给label赋值及取label的值示例_javascript技巧"> <h2> js操作label给label赋值及取label的值示例_javascript技巧 </h2> </a> </li> <li> <a href="/article/334612.html" target="_blank" title="js操作label给label赋值及取label的值示例_javascript技巧"> <h2> js操作label给label赋值及取label的值示例_javascript技巧 </h2> </a> </li> <li> <a href="/article/177943.html" target="_blank" title="VUE 实现动态给对象增加属性,并触发视图更新操作示例"> <h2> VUE 实现动态给对象增加属性,并触发视图更新操作示例 </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>