我想使用ZipFile类,但无法弄清楚如何正确添加名称空间。
ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);
给予
ErrorCS0117 'ZipFile' does not contain a definition for 'CreateFromDirectory'
ErrorCS0117 'ZipFile' does not contain a definition for 'ExtractToDirectory'
我添加了
using System.IO;
using System.IO.Compression;
using System.IO.Compression.FileSystem;
结果
Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression;
将程序集引用添加到
System.IO.Compression
Assembly System.IO.Compression
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.IO.Compression.dll
System.IO.Compression.FileSystem
Assembly System.IO.Compression.FileSystem
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.IO.Compression.FileSystem.dll
试图通过NuGet安装/卸载软件包。重建,甚至重新启动PC。
似乎没有任何作用。 VS中的.Net当前版本为4.7