I want to unzip a file with ZipFile class in c# (VS2012).
Even if I copy the paths directly from win explorer I get this error:
System.ArgumentException: Illegales Zeichen im Pfad. bei
System.IO.Path.CheckInvalidPathChars(String path, Boolean
checkAdditional) bei System.IO.Path.GetFileName(String path) bei
System.IO.Compression.ZipHelper.EndsWithDirChar(String test) bei
System.IO.Compression.ZipArchiveEntry.set_FullName(String value)
bei System.IO.Compression.ZipArchiveEntry..ctor(ZipArchive archive,
ZipCentralDirectoryFileHeader cd) bei
System.IO.Compression.ZipArchive.ReadCentralDirectory() bei
System.IO.Compression.ZipArchive.get_Entries() bei
System.IO.Compression.ZipFileExtensions.ExtractToDirectory(ZipArchive
source, String destinationDirectoryName) bei
System.IO.Compression.ZipFile.ExtractToDirectory(String
sourceArchiveFileName, String destinationDirectoryName, Encoding
entryNameEncoding) bei
System.IO.Compression.ZipFile.ExtractToDirectory(String
sourceArchiveFileName, String destinationDirectoryName) bei
WindowsFormsApplication1.MainForm.buttonStartNxtOSEK_Click(Object
sender, EventArgs e) in
d:C#
xtOSEKInstaller
xtOSEKSetupWindowsFormsApplication1Form1.cs:Zeile
192.
Code:
string zipPath = @"D:C#
xtOSEKInstaller
xtOSEKSetupWindowsFormsApplication1inDebug
espackage.zip";
string extractPath = @"D:estcyginstallcygwin";
textBoxProgress.AppendText("Entpacke .... ");
try {
ZipFile.ExtractToDirectory(zipPath, extractPath);
} catch (System.ArgumentException ex) {
textBoxProgress.AppendText("
" + "Error
" + ex.ToString());
return;
}
EDIT
Problem solved: Some files with chinese file names in the zip file caused the problem.
It's very frustrating when the exception does not output the problematic path name.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…