VB:从互联网下载 ZIP 文件(并解压)
我需要使用 Visual Basic 从 Internet 下载 ZIP 文件。 这是我目前所拥有的:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NewAppData As String
NewAppData = Environment.ExpandEnvironmentVariables("%AppData%/.minecraft.zip")
Call DownloadFile("http://blahblahbacksheep.co.cc/.minecraft.zip", NewAppData)
End Sub
当我调试程序时,它会给出以下信息:
Function 'DownloadFile' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
我想要做的是下载 ZIP 文件,然后解压它。如果可能的话,显示带有百分比的标签,例如:
Downloaded: 100%
Extracting: 35%....
任何人都可以给我任何资源或编写一些代码来执行部分/全部操作吗?
谢谢
I need to somehow download a ZIP file from the internet using Visual Basic.
Here's what I currently have:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NewAppData As String
NewAppData = Environment.ExpandEnvironmentVariables("%AppData%/.minecraft.zip")
Call DownloadFile("http://blahblahbacksheep.co.cc/.minecraft.zip", NewAppData)
End Sub
When I debug the program it gives me the following:
Function 'DownloadFile' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
What I'm looking to do is download the ZIP file and then extract it. And if possible, show label's with percentage for example:
Downloaded: 100%
Extracting: 35%....
Could anyone give me any resources or write up a bit of code to do some/all of this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于您问题的解压缩部分: 7-Zip 是一个非常出色的开源文件归档实用程序有一个很好的命令行界面。下面是如何从 VB 调用 7-Zip 的示例(安装后):
此示例将三个文件压缩到一个存档中,而您想要从存档中提取文件...只需在文档。
请注意,7-Zip 执行时会弹出一个命令窗口,您将在其中看到一个 % 进度指示器。如果您希望此指示器出现在其他位置,那么只需一点点聪明才智,您可以将标准输出通过管道传输到其他相关位置。
For the unzipping part of your question: 7-Zip is a really great, open source, file archiving utility that has a nice command-line interface. Here's an example of how to call 7-Zip from VB (once it's been installed):
This example compresses three files into an archive, while you want to extract files from an archive... just look up the appropriate command for that in the documentation.
Note that a command window will pop up while 7-Zip is executing, and in there you'll see a % progress indicator. If you want this indicator to appear somewhere else, then with a bit of ingenuity you can probably pipe the standard output through to some other relevant location.