LoggingSession.SaveToFileAsync()失败并显示“拒绝访问”

时间:2015-10-29 20:21:23

标签: c# .net windows-store-apps win-universal-app

我写信给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拒绝访问?

0 个答案:

没有答案