我需要使用Shell32解压缩应用程序中的某些文件.现在,我使用srcFolder.CopyHere(destFolder.Items())来实现这一目标.但是,我的下一行代码需要新创建的ZIP文件.但是由于CopyHere方法是Async,如何检查它何时完成?现在,我使用Thread.Sleep大约500毫秒,这足以让我的计算机完成创建ZIP文件的操作,但这不是imo好的代码.
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.
有什么想法吗?
如有必要,可以提供更多的信息/代码.
More info/code can be provided if necessary.
推荐答案我找到了它,使用了类似的东西:
I found it, used something like this:
srcFolder.CopyHere(destFolder.Items()) While FileInUse(FILEPATH & "BudgetJaarOverzichtSMB.zip") Thread.Sleep(100) End While Private Function FileInUse(ByVal FilePath As String) As Boolean Try FileOpen(1, FilePath, OpenMode.Input) FileClose(1) Return False ' File not in use Catch ex As Exception Return True ' File in use End Try End Function并不是很完美,但是与我的第一种方法相比,所花费的时间更少.
Not really perfect but will lose less time than with my first approach.
更多推荐
如何检查Shell32.Folder.CopyHere()完成的时间
发布评论