我希望使用“ZipArchive”类获得ZIP文件中的内容清单。
我正在使用MSDN的示例:
我正在使用MSDN的示例:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Compression;
using System.IO.Compression.dll;
namespace Zip_Extractor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (FileStream zipToOpen = new FileStream(@"c:\users\exampleuser\release.zip", FileMode.Open))
{
using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
{
ZipArchiveEntry readmeEntry = archive.CreateEntry("Readme.txt");
using (StreamWriter writer = new StreamWriter(readmeEntry.Open()))
{
writer.WriteLine("Information about this package.");
writer.WriteLine("========================");
}
}
}
}
}
}
然而,我遇到了错误
'ZipArchive的命名空间找不到'。
我可以确认应用程序的'Target framework'是.NET Framework 4.5。
有人能指点我正确的方向吗?
System.IO.Compression.dll
添加为引用? - Soner Gönül