' System.Reflection.TargetInvocationException'尝试在sdCard WP SL 8.1中创建文件时

时间:2016-03-12 20:15:14

标签: c# windows-phone-8.1 windows-phone-sl-8.1 windows-phone-silverlight

当我尝试在sdCard中的文件夹中创建文件时,我得到此异常。创建文件夹,创建文件,但不写入文本。有人知道为什么吗?因为在我需要访问它之后。 这是我的代码:

StorageFolder myFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MarketApp", CreationCollisionOption.ReplaceExisting);
        StorageFile myFile = await myFolder.CreateFileAsync("Products.txt", CreationCollisionOption.ReplaceExisting);
        Stream f = await myFile.OpenStreamForWriteAsync();
        using (StreamWriter sw = new StreamWriter(f))
        {
            sw.WriteLine("Hello world!");
        }

这些是例外。他们被扔在第二行。

  

未处理的类型' System.Reflection.TargetInvocationException'发生在System.Windows.ni.dll中   附加信息:调用目标抛出了异常。

0 个答案:

没有答案