1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
Public Function WindowsFileCheck(ByVal wPathFile As String) As Boolean
Dim objFSO As Variant
On Error GoTo CatchError
WindowsFileCheck = False
If Trim(wPathFile) = "" Then
Error 9999,"wPathFile is Empty"
Exit Function
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
WindowsFileCheck = objFSO.FileExists(Trim(wPathFile))
Set objFSO = Nothing
Exit Function
CatchError:
MsgBox "("+Structure_Log+" : "+Cstr(GetThreadInfo (1))+" Call by "+Cstr(GetThreadInfo(10))+")"+Chr(10)+"Error " + CStr(Err) + " : "+Chr(10) + CStr(Error)+". "+Chr(10)+"Line # "+Cstr(Erl),16," ERROR !"
WindowsFileCheck = False
Exit Function
End Function
Public Function WindowsFileCopyTo(wPathFileSource As String,wPathFileCible As String,wnbOverWrite As Boolean) As Boolean
Dim objFSO As Variant
Dim PathCible As String
On Error GoTo CatchError
WindowsFileCopyTo = False
If Trim(wPathFileSource) = "" Then
Error 9999,"wPathFileSource is Empty"
Exit Function
End If
If Trim(wPathFileCible) = "" Then
Error 9999,"wPathFileCible is Empty"
Exit Function
End If
PathCible = StrLeftBack(Trim(wPathFileCible),"\")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(Trim(wPathFileSource)) = False Then
Set objFSO = Nothing
Error 9999,"File source not found : "+wPathFileSource
Exit Function
End If
If objFSO.FolderExists (Trim(PathCible)) = False Then
Set objFSO = Nothing
Error 9999,"target folder doesn't exist ("+PathCible+") : "+wPathFileSource+" => "+Trim(wPathFileCible)
Exit Function
End If
If wnbOverWrite = False Then
If objFSO.FileExists(Trim(wPathFileCible)) = True Then
Set objFSO = Nothing
Error 9999,"File target already exist : "+wPathFileCible
Exit Function
End If
End If
Call objFSO.CopyFile(Trim(wPathFileSource),Trim(wPathFileCible),wnbOverWrite)
WindowsFileCopyTo = objFSO.FileExists(Trim(wPathFileCible))
Set objFSO = Nothing
Exit Function
CatchError:
MsgBox "("+Structure_Log+" : "+Cstr(GetThreadInfo (1))+" Call by "+Cstr(GetThreadInfo(10))+")"+Chr(10)+"Error " + CStr(Err) + " : "+Chr(10) + CStr(Error)+". "+Chr(10)+"Line # "+Cstr(Erl),16," ERROR !"
WindowsFileCopyTo = False
Exit Function
End Function |
Partager