0

だから私は今のところ理解できないこの問題を抱えています。パッチを適用したIonic.zipを「http://dotnetzip.codeplex.com/workitem/14049」から取得しました。

通常のc#とその動作にionic.zipを使用して、Silverlight以外のプロジェクトでコードをテストしました。しかし、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;
    }
}
4

1 に答える 1

0

「IBM437」というエラーが発生したのか、コードのどこで発生したのかはわかりませんが、SilverLight では、最初に SelectFileWindow を表示せずにコードからファイル システムにアクセスできないことはわかっています。

つまり、ハードコードされた "c:\temp\gftTempFile.txt" を含む行は、権限を昇格させないと SL アプリでは確実に機能しません。

于 2013-02-06T07:03:14.003 に答える