C# Access denied to path in a Windows Application

前端 未结 4 927
一个人的身影
一个人的身影 2020-12-16 05:36

I\'ve built a Windows Application using c#, on Windows 7.

Everything was working fine, so I\'ve created a Setup Wizard project and then built it. Once I install the

4条回答
  •  无人及你
    2020-12-16 06:05

    The solution is not to grant rights to that directry but to instead write to a folder that is more suitable for application logs. The "Program Files(x86)" and "Program Files" is a place for application installation, not logging.

    A more appropriate location would be the per user data folders

    • %AppData%
    • %LocalAppData%

    Or the result of Environment.GetFolderPath for the following values

    • SpecialFolder.ApplicationData
    • SpecialFolder.LocalApplicationData
    • SpecialFolder.CommonApplicationData

提交回复
热议问题