我写信给StorageFolder
以确保我有权访问它,并在下一行中尝试保存LoggingSession
,但由于“访问被拒绝”而失败。
会话创建:
var channel = new LoggingChannel("Channel1", new LoggingChannelOptions());
var session = new LoggingSession("Session1");
session.AddLoggingChannel(channel, LoggingLevel.Warning);
channel.LogMessage("Test message", LoggingLevel.Error);
写作:
//"folder" is a StorageFolder that as we can see, I do have permission to write to.
StorageFolder folder = await KnownFolders.PicturesLibrary.GetFolderAsync("test");
StorageFile file = await folder.CreateFileAsync("t1.txt", CreationCollisionOption.OpenIfExists);
await FileIO.AppendTextAsync(file, "abc");
var testFile = await session.SaveToFileAsync(folder, "testlog.txt");//access denied
那么为什么LoggingSession
拒绝访问?