我有以下方法在下载后解压缩文件。但它以错误结束
System.ArgumentException 路径为空 System.IO.Directory.CreateDirectory System.String path 0x00000 in ionic.zip.zipentry.internalExtract system.string basedir system.io.stream outstream system.string password 0x00000 in 文件名未知。
zip 文件没有密码,可以打开,例如使用 android zip
public void ExtractBilderZip()
{
string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string unzipziel = Path.Combine(documentsPath, "Bilder");
// if Bilder does not exist create subdirectory
if (Directory.Exists(unzipziel)==false)
{
var directoryname = Path.Combine(documentsPath, "Bilder");
Directory.CreateDirectory(directoryname);
}
//////////////////////////////////////////////////////
string zipToUnpack = localPathB; //localPathB ist the zipFile name including path
// I tried with and wihout the following 2 lines which makes no diffence
zipToUnpack = zipToUnpack.Replace('/', Path.DirectorySeparatorChar);
unzipziel = unzipziel.Replace('/', Path.DirectorySeparatorChar);
try
{
ZipFile zip1 = ZipFile.Read(zipToUnpack);
zip1.ExtractAll(unzipziel,ExtractExistingFileAction.OverwriteSilently);
}
catch (System.Exception ex1)
{
//System.Console.Error.WriteLine("exception: " + ex1);
for (int i = 0; i < 10; i++)
{
Toast.MakeText(this, "exception: " + ex1, ToastLength.Long).Show();
}
}
}