如何检查Shell32.Folder.CopyHere()完成的时间

编程入门 行业动态 更新时间:2024-10-12 03:16:53
本文介绍了如何检查Shell32.Folder.CopyHere()完成的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用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()完成的时间

本文发布于:2023-11-05 18:23:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   Folder   CopyHere

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!