Set fs=Server.CreateObject("Scripting.FileSystemObject")
'來源檔案存在 ---開始---
if fs.FileExists(Src_fName) then
'建立目的資料夾,如果沒有此資料夾,則建立資料夾。
ary_folder = Split(fPath,"\")
Des_fPath = "D:\APfileBK"
Des_fName = Des_fPath & "\" & fName
For i = 0 to UBound(ary_folder)-1
Des_fPath = Des_fPath & "\" & ary_folder(i)
IF not fs.FolderExists(Des_fPath) then
'Response.Write("<br>Des_fPath : " & Des_fPath)
fs.CreateFolder(Des_fPath)
End if
Next
'刪除 '@20141015 檔案有存在,先刪除
if fs.FileExists(Des_fName) then
'response.write("<br>Des_fName File exists! " & Des_fName)
'Flag(true or false):預設值為false,true表可以刪除唯讀屬性 設定的檔案,若不設為 true,則遇到唯讀屬性檔案時將產 生『沒有使用權限』的錯誤 (err.number=70)
fileOpen.close '關閉檔
fs.Deletefile Des_fName,true '刪除檔案 先關閉,才能刪除
end if
'搬移
fs.CopyFile Src_fName,Des_fPath & "\" ,true 'overwrite(是否覆蓋):預設值為true
#####################################################
#T=============================
#T=FSO相關操作
#T= 判斷目錄是否存在
<%
Function IsFloderExist(strFolderName)
SET FSO=Server.CreateObject("Scripting.FileSystemObject")
IF(FSO.FolderExists(strFolderName))THEN
IsFloderExist = True
ELSE
IsFloderExist = False
END IF
SET FSO=NOTHING
End Function
%>
#T= 創建目錄
<%
Function CreateFolder(strFolderName)
SET FSO=Server.CreateObject("Scripting.FileSystemObject")
IF(FSO.FolderExists(strFolderName) = False)THEN
FSO.CreateFolder(strFolderName)
END IF
SET FSO=NOTHING
END Function
%>
#T= 刪除目錄
<%
Function DeleteFolder(strFolderName)
SET FSO=Server.CreateObject("Scripting.FileSystemObject")
IF(FSO.FolderExists(strFolderName))THEN
FSO.DeleteFolder(strFolderName)
END IF
SET FSO=NOTHING
END Function
%>
#T= 判斷文件是否存在
<%
Function IsFileExist(strFileName)
SET FSO=Server.CreateObject("Scripting.FileSystemObject")
IF(FSO.FileExists(strFileName))THEN
IsFileExist = True
ELSE
IsFileExist = False
END IF
SET FSO=NOTHING
End Function
%>
#T= 刪除文件
<%
Function DeleteFile(strFileName)
SET FSO=Server.CreateObject("Scripting.FileSystemObject")
IF(FSO.FileExists(strFileName))THEN
FSO.DeleteFile(strFileName)
END IF
SET FSO=NOTHING
END Function
%>
沒有留言:
張貼留言