You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VB.NET中使用ZipArchive为压缩包添加密码是否可行?

使用ZipArchive无法实现压缩包密码保护
  • .NET自带的System.IO.Compression.ZipArchive类不支持为压缩包设置密码保护,这是该API的原生限制,没有内置属性或方法可直接实现密码加密功能。
  • 若需生成带密码的压缩包,可参考以下两种方案:
    1. 使用第三方库(如DotNetZip,可通过NuGet安装),它提供了简洁的密码设置接口,示例代码如下:
      Using zip As New Ionic.Zip.ZipFile()
          zip.Password = "你的密码"
          zip.AddFile("file1.txt")
          zip.AddFile("file2.txt")
          ' 添加剩余3个文件
          zip.Save("加密压缩包.zip")
      End Using
      
    2. 调用第三方压缩工具的命令行版本(如7z.exe),通过进程调用完成加密压缩,示例代码如下:
      Dim compressProcess As New Process()
      compressProcess.StartInfo.FileName = "7z.exe"
      compressProcess.StartInfo.Arguments = "a -p你的密码 加密压缩包.zip file1.txt file2.txt file3.txt file4.txt file5.txt"
      compressProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
      compressProcess.Start()
      compressProcess.WaitForExit()
      

内容的提问来源于stack exchange,提问作者Tim F

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 20:22:00