Does anymody know of a file copy method I can use from within VB which will give me some kind of progress? Like explorer does when copying large files, or files over a slow network connection.
From an old program I wrote.
Hope I included everything you need.
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Declare Function SHFileOperation _
Lib "shell32.dll" _
Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Public Function CopyFile(ByVal sSource As String, _
ByVal sDest As String, _
Optional bNoConfirmation As Boolean = True, _
Optional nTries As Long = DEFAULTTRIES, _
Optional nWait As Single = DEFAULTWAIT) As Boolean
Dim sh_op As SHFILEOPSTRUCT
Dim nAttempts As Long
On Error GoTo ERRORHANDLER
CopyFile = False
nAttempts = 0
TRYAGAIN:
With sh_op
.hWnd = 0
.wFunc = FO_COPY
.pFrom = sSource & vbNullChar & vbNullChar
.pTo = sDest & vbNullChar & vbNullChar
If bNoConfirmation Then
.fFlags = FOF_NOCONFIRMATION Or FOF_NOCONFIRMMKDIR
Else
.fFlags = FOF_NOCONFIRMMKDIR
End If
End With
If SHFileOperation(sh_op) = 0 Then
CopyFile = True
Else
If sh_op.fAnyOperationsAborted Then
msProblem = "User aborted operation."
Else
msProblem = "Unknown error. Check network connections and/or space available in destination."
End If
CopyFile = False
End If
Exit Function
ERRORHANDLER:
nAttempts = nAttempts + 1
If nAttempts <= nTries Then
waitSeconds nWait
Resume TRYAGAIN
Else
msProblem = "Unable to copy " & sSource & " to " & sDest & _
" (" & Err.Number & ": " & Err.Description & ""
Exit Function
End If
End Function
sorry for this english but i don't speek
is it a function in Vb of in Win where i can copy a file and where i can know the statut of this copy?
I have a probleme whis a "machine"??
it hase a pil of 300 file.I must copy file / file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.