网站制作学习网ASP→正文:asp添加移动删除文件夹
字体:

asp添加移动删除文件夹

ASP 2008/1/25 8:05:16  点击:不统计


asp通过Fso操作文件夹实例

'在根目录下运行,我运行的根目录是c:\asp

<%

if request.QueryString("del")="ok" then

path=request.Form("path") '文件夹的路径

Dbpath=server.mappath(path)

dim fso,strRubbishFile

Set fso = Server.CreateObject("Scripting.FileSystemObject")

if fso.FolderExists(Dbpath) then '判断是否有这文件夹

fso.DeleteFolder(Dbpath) '删除文件夹

end if

end if

if request.QueryString("del")="b" then

nam=request.Form("nam")

Set fso = CreateObject("Scripting.FileSystemObject")

fso.CreateFolder ("c:\asp\try\"&nam&"")

end if

if request.QueryString("del")="m" then

newp=request.Form("n")

oldp=request.Form("o")

Set fso = CreateObject("Scripting.FileSystemObject")

'fso.CreateFolder ("c:\asp\try\"&oldp&"")

fso.MoveFolder "c:\asp\try\"&oldp&"", "C:\asp\try\b\"

end if

%>



<form action="?del=ok" method="post" name="form1"><table width="381" border="0">

<tr>

<td height="70">删除文件夹<input type="text" name="path" size="50" /><input type="button" onclick="form1.submit();" value="确定" /></td>

</tr>

</table>

</form>

<form action="?del=b" method="post" name="form2"><table width="381" border="0">

<tr>

<td height="70">新建文件夹<input type="text" name="nam" size="50" /><input type="button" onclick="form2.submit();" value="确定" /></td>

</tr>

</table>

</form>

<form action="?del=m" method="post" name="form3"><table width="381" border="0">

<tr>

<td height="70">移动文件夹:移动<input type="text" name="o" size="50" alt="文件夹名字" /><br />到<input type="text" size="50" name="n" /><br /><input type="button" onclick="form3.submit();" value="确定" /><br>到那个文件夹后面写个\比如转移到b文件夹那就写b\</td>

</tr>

</table>

</form>

<table width="381" border="0">

<tr>

<td height="70">所有文件夹</td>

</tr>

<tr>

<td height="70"><%

Set fso = CreateObject("Scripting.FileSystemObject")

Set fldr = fso.GetFolder("c:\asp\try")

Response.Write "父文件夹名字是:" & fldr & "<br>"



If fldr.IsRootFolder = True Then

Response.Write "该文件夹是一根文件夹" & "<br>"

Else

Response.Write "该文件夹不是根文件夹" & "<br>"

End If



Response.Write "驱动器名字是:" & fldr.Drive & "<br>"

%></td>

</tr>

</table>



关键词: asp新建移动删除文件夹 新建 移动 删除 asp

·上一篇:ASP与Access数据库连接 >>    ·下一篇:打开页从头开始 >>
推荐文章
最新文章