C#Windows窗体应用程序:在创建安装程序/安装程序时为用户的目录设置写入权限 [英] C# Windows Form Application : Set write permission to user's directory while creating Installer/Setup

查看:71
本文介绍了C#Windows窗体应用程序:在创建安装程序/安装程序时为用户的目录设置写入权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于Windows窗体的应用程序,并将一些日志详细信息写入文件logs.txt。此文件位于另一个名为Logs的文件夹中。在本地没有发现问题,但是当我创建它并安装在我的机器上时,我发现Logs目录上没有写入权限。当我给予完全许可时,它再次正常工作。



在创建Windows窗体应用程序的安装项目时,有没有办法提供完全权限?



上述问题可在Windows 7上找到。

I have created a Windows Form based application and writing some logs detail in a file as "logs.txt". This file is available in another folder named as "Logs". No issue found on local, but when i create Setup of it and install in on my machine i found that write permission is not available on "Logs" directory. When i give full permission then again it working fine.

Is there any way to provide full permission when creating an Setup project of my Windows Form application?

The above issue were found on Windows 7.

推荐答案

最佳解决方案是不要。

将您的日志文件移动到已经拥有权限的地方:其中我应该存储我的数据吗? [ ^ ]应该有帮助。



将数据存储在固定(或相对于应用程序EXE)文件夹中应该很难防止病毒活动,随着时间的推移,它可能会变得更加困难。它也不太可能定期备份Program Files下的任何内容。
The best solution is "don't".
Move your logs file to somewhere that already has permission: Where should I store my data?[^] should help.

Storing data in a fixed (or relative to the application EXE) folder is supposed to be difficult to prevent virus activity, and it's likely to get more difficult as time goes on. It's also less likely that anything under "Program Files" will be regularly backed up.


你好,



u只需添加一个应用程序清单文件在您的项目中。并将凭据更改为管理员。像这样

Hello,

u just add one application manifest file in your project . and change the credential to the administrator . like this
<security>
      <requestedprivileges xmlns="urn:schemas-microsoft-com:asm.v3">
 <!-- 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.
        -->

   <requestedexecutionlevel level="requireAdministrator" uiaccess="false" />
 
      </requestedprivileges>
    </security>





谢谢



thanks


这篇关于C#Windows窗体应用程序:在创建安装程序/安装程序时为用户的目录设置写入权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆