我正在尝试做一个非常非常基本的操作:
public async Task WriteAsync(string path)
{
// Write to text file
try
{
lines = "Hello, World";
File.WriteAllText("Assets\\Write.txt", lines);
}
catch (System.Exception e)
{
lines = e.Message;
}
}
我收到以下异常:
{System.UnauthorizedAccessException:拒绝访问路径'....... AppX \ Assets'。
at System.IO.Win32FileStream..ctor(String path,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options,FileStream parent)
at System.IO.Win32FileSystem.Open(String fullPath,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options,FileStream parent)
at System.IO.MultiplexingWin32WinRTFileSystem.Open(String fullPath,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options,FileStream parent)
at System.IO.FileStream.Init(String path,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options)
at System.IO.File.InternalWriteAllText(String path,String contents,Encoding encoding)
at System.IO.File.WriteAllText(String path,String contents)
在SynSent18.KnowledgeBase.d__8.MoveNext()}
我将资产设置为Everyone完全控制。我甚至试图在Windows中预先创建文件并给予完全控制。错误仍然存在。
想法?