【发布时间】:2016-08-03 20:55:05
【问题描述】:
我正在尝试将字符串附加到文本文件中,但出现以下异常
An exception of type 'System.UnauthorizedAccessException' occurred in System.IO.FileSystem.dll but was not handled in user code
Additional information: Access to the path 'E:\Dev\interactiveappdev_groupproject\CardGameSol\CardGame\bin\x86\Debug\AppX\Cards\Data\myCards.txt' is denied.
代码是
string path = @"Folder1\\Folder2\\file.txt";
System.IO.File.AppendAllText(path, "text content");
如何解决这个问题? 将字符串附加到 txt 文件中的最佳方法是什么?
【问题讨论】:
-
这听起来像是权限问题。尝试将文件放在 bin 目录之外的某个位置。
-
如果用户从商店下载应用程序,它会起作用吗?如果是,如何改变它
标签: c# visual-studio append win-universal-app