asp 文件、文件夹操作函数
2007-09-24 22:29
429 查看
'建立文件夹的函数1:
Sub CreateFolderOne(strFolder)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
response.write "<h1><font color=red>该文件夹已经存在!</font></h1>"
Else
strTestFolder = Server.Mappath(strFolder)
' 建立文件夹
objFSO.CreateFolder(strTestFolder)
Set objFSO = Nothing
End If
End Sub
'建立文件夹的函数2:
Sub CreateFolder(strFolder,ifok)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
IF Ifok<>"" Then
strFolder="../"&strFolder
End IF
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
response.write "<h1><font color=red>该文件夹已经存在!</font></h1>"
Else
strTestFolder = Server.Mappath(strFolder)
' 建立文件夹
objFSO.CreateFolder(strTestFolder)
Set objFSO = Nothing
End If
End Sub
'删除文件夹的函数:
Sub DeleteFolder(strFolder)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
objFSO.DeleteFolder(strTestFolder)
Else
response.write "<h1><font color=red>该文件夹不存在!</font></h1>"
End If
Set objFSO = Nothing
End Sub
'删除文件函数:
Sub DeleteFile(FileName)
'首选判断要建立的文件夹是否已经存在
Dim strTestFile, objFSO
strTestFile = Server.Mappath(FileName)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件是否存在
If objFSO.FileExists(strTestFile) Then
objFSO.DeleteFile(strTestFile)
Else
response.write "<h1><font color=red>该文件夹不存在!</font></h1>"
End If
Set objFSO = Nothing
End Sub
'-------------------复制文件--------
Function CopyFiles(TempSource,TempEnd)
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
IF FSO.FileExists(TempEnd) then
Response.Write "目标备份文件 <b>" & TempEnd & "</b> 已存在,请先删除!"
Set FSO=Nothing
Exit Function
End IF
IF FSO.FileExists(TempSource) Then
Else
Response.Write "要复制的源数据库文件 <b>"&TempSource&"</b> 不存在!"
Set FSO=Nothing
Exit Function
End If
FSO.CopyFile TempSource,TempEnd
Response.Write "已经成功复制文件 <b>"&TempSource&"</b> 到 <b>"&TempEnd&"</b>"
Set FSO = Nothing
End Function
Sub CreateFolderOne(strFolder)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
response.write "<h1><font color=red>该文件夹已经存在!</font></h1>"
Else
strTestFolder = Server.Mappath(strFolder)
' 建立文件夹
objFSO.CreateFolder(strTestFolder)
Set objFSO = Nothing
End If
End Sub
'建立文件夹的函数2:
Sub CreateFolder(strFolder,ifok)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
IF Ifok<>"" Then
strFolder="../"&strFolder
End IF
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
response.write "<h1><font color=red>该文件夹已经存在!</font></h1>"
Else
strTestFolder = Server.Mappath(strFolder)
' 建立文件夹
objFSO.CreateFolder(strTestFolder)
Set objFSO = Nothing
End If
End Sub
'删除文件夹的函数:
Sub DeleteFolder(strFolder)
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder, objFSO
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件夹是否存在
If objFSO.FolderExists(strTestFolder) Then
objFSO.DeleteFolder(strTestFolder)
Else
response.write "<h1><font color=red>该文件夹不存在!</font></h1>"
End If
Set objFSO = Nothing
End Sub
'删除文件函数:
Sub DeleteFile(FileName)
'首选判断要建立的文件夹是否已经存在
Dim strTestFile, objFSO
strTestFile = Server.Mappath(FileName)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' 检查文件是否存在
If objFSO.FileExists(strTestFile) Then
objFSO.DeleteFile(strTestFile)
Else
response.write "<h1><font color=red>该文件夹不存在!</font></h1>"
End If
Set objFSO = Nothing
End Sub
'-------------------复制文件--------
Function CopyFiles(TempSource,TempEnd)
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
IF FSO.FileExists(TempEnd) then
Response.Write "目标备份文件 <b>" & TempEnd & "</b> 已存在,请先删除!"
Set FSO=Nothing
Exit Function
End IF
IF FSO.FileExists(TempSource) Then
Else
Response.Write "要复制的源数据库文件 <b>"&TempSource&"</b> 不存在!"
Set FSO=Nothing
Exit Function
End If
FSO.CopyFile TempSource,TempEnd
Response.Write "已经成功复制文件 <b>"&TempSource&"</b> 到 <b>"&TempEnd&"</b>"
Set FSO = Nothing
End Function
相关文章推荐
- asp结合fso实现文件或文件夹创建删除等操作的函数
- asp下利用fso实现文件夹或文件移动改名等操作函数
- asp结合fso实现文件或文件夹创建删除等操作的函数
- asp下利用fso实现文件夹或文件移动改名等操作函数
- ASP中最常用的22个FSO文件操作函数1-11
- PB利用API-SHFileOperation 文件操作函数 实现多文件及文件夹的删除复制等操作
- 总结ASP操作文件夹和文件(转)
- php文件夹与文件目录操作函数介绍
- ASP.NET操作文件(文件夹)简单生成html操作示例
- go语言中常用的文件和文件夹操作函数
- JAVA文件/文件夹操作实用函数
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(一)
- 总结文件操作函数-文件夹(三)-C语言
- asp.net文件操作小例子(创建文件夹,读,写,删)
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(一)
- Asp.Net文件和文件夹操作大全
- python中对文件、文件夹(文件操作函数)的操作
- asp.net 操作文件和文件夹的类
- Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(二)