C# Access denied to path in a Windows Application

前端 未结 4 929
一个人的身影
一个人的身影 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条回答
  •  旧时难觅i
    2020-12-16 06:00

    To add to what Reed Copsey and JaredPar wrote in their answers:

    Writing to the "Program Files" or "Program Files (x86)" directories is not advisable, and for good reason. The reason for this is that granting permissions for any application to write and/or change files in these directories is a security problem - it allows program that are "jeopardized" (e.g. your browser, in case it has a security bug) to alter programs files, infecting them with viruses or worms, etc.

    Windows has dedicated folders for application and user data, and any program accessing data in these folders is expected to treat it as "untrusted data" due to the lower security restrictions on those folders. One such folder is Environment.SpecialFolders.ApplicationData - as indicated by Reed.

提交回复
热议问题