Click to See Complete Forum and Search --> : How to DoEvents during a filecopy?
Braniac
September 7th, 2001, 07:58 AM
Grzzz,
I'm writing an application in which I have to copy a large amount of files over a slow network connection. I'm doing this through the shFileOp API, which looks nice.
However, there seems to be no way to keep processing events during the copy process so my main form hangs for 20 minutes.
Anyone know how to solve this?
Thanx,
Braniac.
Andrew R.
September 7th, 2001, 09:40 AM
The only way is to put that copy task in separate thread.
Unfortunately I have no experience of doing this in VB.
DSJ
September 7th, 2001, 01:34 PM
I wrote up a quick and dirty to test this and my app still processes events while the SHFileOperation function is running... click on button2 during a copy and msgbox shows...
option Explicit
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 Const FO_DELETE = &H3
private Const FO_COPY = &H2
private Const FO_MOVE = &H1
private Const FO_RENAME = &H4
private Const FOF_ALLOWUNDO = &H40
private Const FOF_FILESONLY = &H80
private Const FOF_CONFIRMMOUSE = &H2
private Const FOF_MULTIDESTFILES = &H1
private Const FOF_NOCONFIRMATION = &H10
private Const FOF_NOCONFIRMMKDIR = &H200
private Const FOF_NOERRORUI = &H400
private Const FOF_NORECURSION = &H1000
private Const FOF_RENAMEONCOLLISION = &H8
private Const FOF_SILENT = &H4
private Const FOF_SIMPLEPROGRESS = &H100
private Const FOF_WANTMAPPINGHANDLE = &H20
private Const FOF_WANTNUKEWARNING = &H4000
private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp as SHFILEOPSTRUCT) as Long
private Sub Command1_Click()
Dim FS as SHFILEOPSTRUCT
FS.hWnd = me.hWnd
FS.pFrom = "C:\somebigfile"
FS.pTo = "C:\someotherfile"
FS.wFunc = FO_COPY
FS.fFlags = FOF_NOCONFIRMATION
SHFileOperation FS
End Sub
private Sub Command2_Click()
MsgBox "Hello"
End Sub
Braniac
September 10th, 2001, 04:52 AM
You´re RIGHT!
Maybe it´s because I had not implemented the filop yet, and was still using FileCopy instead!
Thanx anyway!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.