好的,我已经搜索了dll文件,这将允许我打开文件,我能够找到相当多的文件,如unrar.dll,chilkat,锐化压缩等等,但是我想使用Rar自己提供的文件。
因此,我在我的项目中引用了DLL文件并导入了它。我在用unrar.dll。
但我无法找到任何最新的代码,让我可以测试和尝试的东西。我发现的所有示例要么不是最新的,要么不是针对Vb.net的。
我也尝试了官方的例子,这是在安装中出现的,但是即使在我修复了它之后,它也没有工作,而且当我尝试使用代码时,我总是得到一个错误
object reference not set to an instance of an object我只想将rar文件从特定位置解压缩到我的程序的根目录,所以如果我的程序在桌面上,我希望它能解压缩文档中的文件并将文件解压缩到我的桌面。
发布于 2013-08-30 02:31:44
如果您只想解压缩文件,我可以用SharpCompress来实现。
首先,我创建了一个新的VB.Net应用程序,并在使用此代码从Rar文件中提取所有文件之前添加了对SharpCompress.dll的引用。
'Imports
Imports SharpCompress.Archives
Imports SharpCompress.Common
'Unrar code
Dim archive As IArchive = ArchiveFactory.Open("C:\file.rar")
For Each entry In archive.Entries
If Not entry.IsDirectory Then
Console.WriteLine(entry.Key)
entry.WriteToDirectory("C:\unrar", New ExtractionOptions With
{.ExtractFullPath = True, .Overwrite = True})
End If
Next更多代码示例
发布于 2018-05-22 09:01:20
对于那些将在vb.net中尝试的人,摘录选项被重命名为
Dim options As New ExtractionOptions With {
.ExtractFullPath = True,
.Overwrite = True
}
entry.WriteToDirectory(Application.StartupPath, options)https://stackoverflow.com/questions/18522605
复制相似问题