- <%
-
- '获取几级文件夹或文件名称
- arr=Split(Request.ServerVariables("SCRIPT_NAME"),"/")
- wenjianjia_name=arr(2)
- response.Write(wenjianjia_name&"<br />")
-
- '文件所在文件夹名称
- cur_URL = Server.MapPath(".")
- arr_curURL = split(cur_URL,"\")
- len_arr = ubound(arr_curURL)
- this_curURL= arr_curURL(len_arr)
- response.Write(this_curURL&"<br />")
-
- '文件名称
- cur_URL = Request.ServerVariables("url")
- arr_curURL = split(cur_URL,"/")
- len_arr = ubound(arr_curURL)
- this_curURL= arr_curURL(len_arr)
- response.Write(this_curURL&"<br />")
-
- folder="www.yuzhiguo.com"'需要创建的文件夹名称
-
- Call createfolder(folder)
-
- Function createfolder(folder)
- set fs=createobject("scripting.filesystemobject")
- url=server.mappath(folder)
- if Not fs.folderexists(url) then
- fs.createfolder(url)
- Response.write url&"创建成功!<br />"
- else
- Response.write url&"存在!<br />"
- end if
- End Function
-
-
- '-------------------复制文件--------
- TempSource= Server.MapPath("/yuzhiguo.jpg")'源文件
- TempEnd=Server.MapPath(folder&"/yuzhiguo.jpg")'移动目标地
- Call CopyFiles(TempSource,TempEnd)
-
- Function CopyFiles(TempSource,TempEnd)
- Dim FSO
- Set FSO = Server.CreateObject("Scripting.FileSystemObject")
- IF FSO.FileExists(TempEnd) then
- Response.Write "目标备份文件 <b>" & TempEnd & "</b> 已存在,请先删除!<br />"
- Set FSO=Nothing
- Exit Function
- End IF
- IF FSO.FileExists(TempSource) Then
- Else
- Response.Write "要复制的源数据文件 <b>"&TempSource&"</b> 不存在!<br />"
- Set FSO=Nothing
- Exit Function
- End If
- FSO.CopyFile TempSource,TempEnd
- Response.Write "已经成功复制文件 <b>"&TempSource&"</b> 到 <b>"&TempEnd&"</b><br />"
- Set FSO = Nothing
- End Function
-
- '-------------------删除文件夹--------
- strFolder="www.yuzhiguo.com"'需要删除的文件夹名称
- Call DeleteFolder(strFolder)
-
- Function DeleteFolder(strFolder)
- '首选判断要建立的文件夹是否已经存在
- Dim strTestFolder, objFSO
- strTestFolder = Server.Mappath(strFolder)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- ' 检查文件夹是否存在
- If objFSO.FolderExists(strTestFolder) Then
- objFSO.DeleteFolder(strTestFolder)
- response.write "<font color=red>删除成功!</font><br />"
- Else
- response.write "<font color=red>该文件夹不存在!</font>"
- End If
- Set objFSO = Nothing
- End Function
- %>
posted @
2011-09-23 17:18
#i小龙#
阅读(
4177)
评论()
编辑
收藏
举报