aspose.zip
时间: 2023-09-16 20:06:53 浏览: 118
Aspose.Zip是一个用于.NET平台的API,它支持从压缩格式(如RAR,ZIP,7Z等)的存档中提取文件,并且可以创建新的ZIP存档。你可以使用Aspose.Zip来处理文件夹,并将其添加到ZIP存档中。最新版本是V20.3。以下是一个在C#中使用Aspose.Zip创建ZIP存档的代码示例:
```csharp
// 创建输出ZIP存档的FileStream
using (FileStream zipFile = File.Open("compress_directory.zip", FileMode.Create))
{
using (Archive archive = new Archive())
{
// 要压缩的文件夹
DirectoryInfo directory = new DirectoryInfo("CanterburyCorpus");
archive.CreateEntries(directory); // 将文件夹添加到ZIP存档
archive.Save(zipFile); // 保存ZIP存档
}
}
```
如果你想在C#中创建受密码保护的ZIP存档,可以使用Aspose.Zip提供的相应功能来设置密码。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [想要以编程方式从RAR中解压缩或提取文件?Aspose.ZIP帮你轻松搞定](https://blog.csdn.net/mnrssj/article/details/116005335)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [想要用编程方式将文件添加到ZIP存档?Aspose.ZIP帮你快速解决](https://blog.csdn.net/mnrssj/article/details/105793277)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文