How to check when Shell32.Folder.CopyHere() is finished

Jelle Capenberghs picture Jelle Capenberghs · Apr 6, 2012 · Viewed 8.1k times · Source

I need to unzip en zip some files in my application using Shell32. Right now, I use srcFolder.CopyHere(destFolder.Items()) to achieve this. However, my next line of code requires the newly made ZIP-file. But since the CopyHere method is Async, how can I check when it in finished? Right now I use a Thread.Sleep for around 500 ms which is enough for my computer to finish creating the ZIP file, but it's not good code imo.

Any ideas?

More info/code can be provided if necessary.

Answer

Fid picture Fid · May 17, 2013

Here is another one for waiting to finish copying

'Wait until the File/Folder has finished writing to zip file...
Do Until Shell.NameSpace(Filename).Items.Count = Shell.NameSpace(Input).Items.Count
    System.Threading.Thread.Sleep(200)
    System.Diagnostics.Debug.Print("Waiting...")
Loop