.NET-SevenZipSharp重命名/删除存档中的文件

时间:2018-08-11 17:52:37

标签: .net vb.net

我想重命名和/或删除7z存档中的文件

当我使用此代码(即没有密码)时,它可以工作。它创建拉链。我可以在7zip中打开它,并在第一步中创建的档案中提取文件等。同样,第一个文件被重命名,第二个被删除。

    Dim Compressor As New SevenZip.SevenZipCompressor
    Compressor.EncryptHeaders = True

    Compressor.CompressFiles("d:\temp\test.7z", {"D:\Temp\svg.txt", "D:\Temp\tmp.txt"})

    Dim NewList = New Dictionary(Of Integer, String)
    NewList.Add(0, "newsvg.txt")
    NewList.Add(1, Nothing)

    Compressor.ModifyArchive("d:\temp\test.7z", NewList)

但是此代码没有-抛出异常,抱怨密码错误。像上面一样,创建的存档很好-只是ModifyArchive遇到了麻烦。

    Dim Compressor As New SevenZip.SevenZipCompressor
    Compressor.EncryptHeaders = True

    Compressor.CompressFilesEncrypted("d:\temp\test.7z", "password", {"D:\Temp\svg.txt", "D:\Temp\tmp.txt"})

    Dim NewList = New Dictionary(Of Integer, String)
    NewList.Add(0, "newsvg.txt")
    NewList.Add(1, Nothing)

    Compressor.ModifyArchive("d:\temp\test.7z", NewList, "password")

我试图读取https://github.com/tomap/SevenZipSharp/blob/master/SevenZip/SevenZipCompressor.cs上的代码,以查看密码路径中是否存在其他内容,但是我的C#不够理想-尤其是涉及编译器命令时。

0 个答案:

没有答案