使用锐压缩包在c#中提取rar文件时遇到错误,我已经尝试过Nunrar,sevenzip提取器和这么多包,但是面临同样的错误
String filename = @"" + textBox8.Text;
string ppath = @"" + System.IO.Path.GetDirectoryName(textBox8.Text) + "\" + System.IO.Path.GetFileNameWithoutExtension(textBox8.Text);
System.IO.Directory.CreateDirectory(@"" + ppath);
try
{
var archive = SharpCompress.Archives.Rar.RarArchive.Open(filename);
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory(ppath, new ExtractionOptions()
{
});
}
}
catch(Exception ex)
{
textBox10.Text = Convert.ToString(ex);
}
最后我解决了 NunRar 支持 Rar4 格式
字符串文件名 = @" + 文本框8.文本; string ppath = @" + System.IO.Path.GetDirectoryName(textBox8.Text( + "\" + System.IO.Path.GetFileNameWithoutExtension(textBox8.Text(; 字符串 ext = textBox7.Text.Substring(textBox7.Text.IndexOf("."((;
try
{
if (ext == ".rar")
{
System.IO.Directory.CreateDirectory(@"" + ppath);
try
{
NUnrar.Archive.RarArchive.WriteToDirectory(filename, ppath, NUnrar.Common.ExtractOptions.ExtractFullPath | NUnrar.Common.ExtractOptions.Overwrite);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else if (ext == ".zip")
{
System.IO.Directory.CreateDirectory(@"" + ppath);
try
{
ZipFile.ExtractToDirectory(filename, ppath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}