0

当我尝试在 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.Windows.ni.dll 中发生了“System.Reflection.TargetInvocationException”类型的未处理异常附加信息:调用目标引发了异常。

4

0 回答 0