1
下載後我有以下方法解壓縮文件。但它與錯誤發生xamarin離子拉鍊解壓縮導致錯誤
System.ArgumentException System.IO.Directory.CreateDirectory上的路徑爲空System.String路徑0x00000在文件unknown.zip.zipentry.internalExtract中未知system.string basedir system.io.stream outstream系統字符串密碼0x00000在filname未知。
ZIP文件中沒有密碼,可以運行結束e.G與Android拉鍊
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();
}
}
}
我通過使用名爲ZipStorer的類來解決我的問題,該類是通過googleing發現的。我在這裏找到它:https://zipstorer.codeplex.com/它很小,很容易使用! – user1230268