asp的文件函數

| |
[不指定 2008/03/31 16:19 | by Else ]
紅過一時間的修改,現在的這個終於可以用了
<%
'request.ServerVariables("APPL_PHYSICAL_PATH")  這個是站點路徑
'FSO组件名称
dim FSObject
FSObject="Scripting.FileSystemObject"
'=========================================================
'◆是否支持组件
'=========================================================
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function

'=========================================================
'fso 操作
'=========================================================
'◆检查某一目录是否存在
'=========================================================
Function CheckDirs(folderpath)
  folderpath=server.MapPath("../company/"&folderpath)
  Set fso= CreateObject(FSObject)
  If fso.FolderExists(folderpath) then  '如果存在就True
    CheckDirs = True
  Else
    CheckDirs = False
  End if
  Set fso= nothing
End Function
'=========================================================
'◆ 根据指定名称生成目录
'=========================================================
Function MakeNewsDir(foldername)
  dim fs0
  Set fso= CreateObject(FSObject)
  Set fs0= fso.CreateFolder(foldername)
  Set fso = nothing
  MakeNewsDir= foldername
End Function
'=========================================================
'◆ 如果文件夹不存在则建立新文件夹 ◆
'=========================================================
Function checkFolder(folderpath)
  If CheckDirs(folderpath) = false Then  '如果文件夹不存在
    MakeNewsDir(folderpath)        '就建一个文件夹
    checkFolder=true
  else
    checkFolder=false
  end if
end Function
'=========================================================
'◆ 删除文件夹 ◆
'=========================================================
Function DeleteFoldera(foldername)
dim path
Set fso = CreateObject(FSObject)
fso.DeleteFolder(foldername)
Set fso = nothing
end Function

'=========================================================
'◆ 如果文件夹存在则刪除 ◆
'=========================================================
Function deleteFolder(folderpath)
  If CheckDirs(folderpath) = true Then  '如果文件夹不存在
    DeleteFoldera(folderpath)      '刪除成功
    deleteFolder=true
  else
    deleteFolder=false
  end if
end Function
'=========================================================
'◆ 更改文件夹名称 ◆
'=========================================================
Function RenameFolder(foldername,newfoldername)
  If CheckDirs(foldername) = false then
    RenameFolder=false
  Elseif CheckDirs(newfoldername)= true then
    RenameFolder=false
  Else
    Set fso = CreateObject(FSObject)
    fso.moveFolder foldername,newfoldername
    RenameFolder=true
    Set fso =nothing
  End if
End Function

'=========================================================
'◆ 删除指定文件 ◆
'=========================================================
Function DeleteFile(file)
  Set fso = CreateObject(FSObject)
  fso.DeleteFile file
  Set fso = nothing
End Function

'以下目錄,都在compay這個目錄下
'response.Write "<br>文件夾是否存在"&CheckDirs("aabbaa")
'response.Write "<br>文件夾是否刪除"&deleteFolder("aabbaa")
'response.Write "<br>文件夾是否存在"&CheckDirs("aabbaa")
'response.Write "<br>文件夾是否創建"&checkFolder("aabbaa")
'response.Write "<br>文件夾是否存在"&CheckDirs("aabbaa")
'response.Write "<br>文件夾是否改名"&RenameFolder("aabbaa","adfasaffad")

%>


作者:Else 's Blog
地址:http://www.aixq.com/post/978/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“asp的文件函數”相关内容
  • 中查看更多“asp的文件函數”相关内容
  • 中查看更多“asp的文件函數”相关内容
  • 中查看更多“asp的文件函數”相关内容
  • 中查看更多“asp的文件函數”相关内容
  • 中查看更多“asp的文件函數”相关内容

  • 最后编辑: Else 编辑于2008/04/08 08:05
    Tags:
    代码 程序 编程 | 评论(0) | 引用(0) | 阅读(755)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]
                   

    验证码 不区分大小写