AlexF777
asked on
Looking for code to copy file accross a network using clipboard ( just like Windows Explorer does )
only without GUI interface
Somehow, Windows Explorer copies files accross a network much faster then regular copy command. ( Would be nice to understand why. )
Therefore, we are trying to emulate it's actions for our own purposes.
Thanks,
Somehow, Windows Explorer copies files accross a network much faster then regular copy command. ( Would be nice to understand why. )
Therefore, we are trying to emulate it's actions for our own purposes.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
works great, although there is still some progress bar showing up
not sure how to get rid of it
may be .fFlags = ...
not sure how to get rid of it
may be .fFlags = ...
ASKER
I got it : FOF_SILENT
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Const FO_COPY = &H2
Const FO_DELETE = &H3
Const FO_MOVE = &H1
Const FO_RENAME = &H4
Const FOF_ALLOWUNDO = &H40
Const FOF_SILENT = &H4
Const FOF_NOCONFIRMATION = &H10
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMMKDIR = &H200
Const FOF_FILESONLY = &H80
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Sub Command1_Click()
Dim result As Long, fileop As SHFILEOPSTRUCT
With fileop
.hwnd = Me.hwnd
.wFunc = FO_COPY
.pFrom = "c:\Somedir\MyFile.xls" & vbNullChar & vbNullChar
.pTo = "\\ServerName\ShareName\My
.fFlags = FOF_NOCONFIRMMKDIR
End With
result = SHFileOperation(fileop)
If result <> 0 Then
' Operation failed
MsgBox Err.LastDllError
End If
End Sub