2

我为从 windows 目录读取数据的遗留应用程序编写了一个接口。

所以我需要将数据写入windows目录。(Windows 8 操作系统)

我正在使用下面的代码来获取写入文件的 Windows 文件夹路径。

Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "test.txt");

正如我在MSDN上所读到的,如果我们运行应用程序,作为普通用户,它会将数据写入虚拟存储 Windows 文件夹,但它似乎无法正常工作。我收到拒绝访问错误。

我的应用程序使用 x86 平台构建。

我缺少的东西或 Windows 8 操作系统的任何限制。

请协助,非常感谢提前。

4

1 回答 1

3

我在提供的清单文件默认注释中找到了我的问题的答案。它说,

<!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            Specifying requestedExecutionLevel node will disable file and registry virtualization.
            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->

因此,您需要添加清单文件并从 xml 或项目属性 -> 应用程序 -> 图标和清单 -> 清单集下删除requestedExecutionLevel节点

Create application without a manifest

它解决了我的问题。

谢谢,

于 2014-04-28T09:42:06.750 回答