我正在做一个将 .zip 文件解压缩到路径“C:\Program Files (x86)”的项目。它返回错误:
Ionic.Zip.dll 中出现“System.UnauthorizedAccessException”类型的未处理异常
我搜索了很多,但我无法理解解决此问题的方法。请帮帮我 。
我的代码:
namespace UTAD__VPN_w7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buscarpasta()
{
DialogResult result = this.folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
/*string pedro = folderBrowserDialog1.SelectedPath;
string pedro2 = pedro.Replace("\\", "\\\\");
textBox1.Text = pedro2;*/
string pasta1 = folderBrowserDialog1.SelectedPath;
var pasta2 = pasta1.Replace(@"\", @"\\");
textBox1.Text = pasta2;
}
}
private void MyExtract()
{
string zipToUnpack = "C:\\Users\\Zé Eduardo\\Music\\Cisco.zip";
string unpackDirectory = textBox1.Text;
using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
{
// here, we extract every entry, but we could extract conditionally
// based on entry name, size, date, checkbox status, etc.
foreach (ZipEntry e in zip1)
{
e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
buscarpasta();
}
}
我得到文件夹browserdialog1的路径,然后我解压缩单击按钮1