我从这里与 SevenZSharp 合作
对于我使用的解码文件:
CompressionEngine.Current.Decoder.DecodeIntoDirectory(@"D:\target\host_update.7z", @"D:\target");
但我不知道如何用密码解码 .7z 文件!?请帮我。谢谢
我从这里与 SevenZSharp 合作
对于我使用的解码文件:
CompressionEngine.Current.Decoder.DecodeIntoDirectory(@"D:\target\host_update.7z", @"D:\target");
但我不知道如何用密码解码 .7z 文件!?请帮我。谢谢
要使用支持密码和多种格式的“SevenZipSharp”...
将 SevenZipSharp.dll 导入 .Net 项目引用...
将“7zx64.dll”和“7z.dll”放入目录...
然后使用此代码检查通过并提取是否正确..
代码
Imports SevenZip
Public Class FrmMain
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Btn1.Click
''Call to set DLL depending on processor type''
If Environment.Is64BitProcess Then
SevenZip.SevenZipCompressor.SetLibraryPath("7zx64.dll")
Else
SevenZip.SevenZipCompressor.SetLibraryPath("7z.dll")
End If
''Set Destination of extraction''
Dim DestDir = Application.StartupPath
Try
''Check file with password''
Dim Ext As New SevenZipExtractor(Tb1.Text, Tb2.Text)
If Ext.Check() Then
''Extract files to destination''
Ext.BeginExtractArchive(DestDir)
End If
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class
从 SevenZSharp 的源代码来看,它不支持受密码保护的文件。
这里还有一些可以从 codeplex 帮助你的东西。如果 7z 受密码保护,它似乎有一个名为ICryptoGetTextPassword
您可以使用的界面。
编辑
进一步看一下 SevenZipSharp ,它似乎应该支持密码保护的档案,以符合他们的项目页面(http://sevenzipsharp.codeplex.com/):
- 支持加密和密码。
您需要从Codeplex下载最新代码并自己构建它,在其中您将有一个名为的类SevenZipExtractor
,其中您有以下构造函数:
/// <summary>
/// Initializes a new instance of SevenZipExtractor class.
/// </summary>
/// <param name="archiveFullName">The archive full file name.</param>
/// <param name="password">Password for an encrypted archive.</param>
public SevenZipExtractor(string archiveFullName, string password)
: base(password)
{
Init(archiveFullName);
}
请注意,这与 Seven7Sharp 不同,这是 SevenZipSharp,但它适用于7z
.