所以我遇到了这个我目前无法弄清楚的问题。我已经从“ http://dotnetzip.codeplex.com/workitem/14049 ”获取了修补过的 Ionic.zip 。
我使用 ionic.zip 在一个非silverlight项目上测试了我的代码,用于常规 c# 及其工作。但是在修改 silverlight(lightswitch) 的代码时,我不断收到“IBM437”错误。
这是我的代码的样子
void selectFileWindow_Closed(object sender, EventArgs e)
{
SelectFileWindow selectFileWindow = (SelectFileWindow)sender;
string selectFileStream = sender.ToString();
var parsedString = selectFileStream.Split(',');
if (selectFileWindow.DialogResult == true && (selectFileWindow.myStream != null))
{
foreach (FileStream myZippedStream in selectFileWindow.myStream)
{
string zippedLocation = myZippedStream.Name;
var parsedLocation = zippedLocation.Split('\\');
string fileName = parsedLocation[parsedLocation.Length - 1];
//filename is equal to something like "myfile.zip"
// We want to turn that to "myfile.txt)
fileName = (fileName.Substring(0, fileName.Length - 3)) + "txt";
using (FileStream fs = File.Create("c:\\temp\\gftTempFile.txt"))
{
using (var ms = new MemoryStream())
{
//ReadOptions myOptions = new ReadOptions();
//myOptions.Encoding = System.Text.Encoding.UTF8;
//using (ZipFile myZip = ZipFile.Read(myZippedStream, myOptions))
// I have tried using the commentted code but it gives the same error
using (ZipFile myZip = ZipFile.Read(myZippedStream))
{
ZipEntry myEntry = myZip[fileName];
myEntry.Extract(ms);
ms.WriteTo(fs);
fs.Close();
ImportGift.importGift(fs, this.DataWorkspace);
try
{
fs.Close();
fs.Dispose();
ms.Close();
ms.Dispose();
File.Delete("c:\\temp\\gftTempFile.txt");
}
catch { }
}
}
}
}
doneLoading = true;
}
}