Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write-access for c# app in its own exe dir in Windows 7

I know that user accounts in Windows 7 are limited by default, so a program cannot just write anywhere on the system (as it was possible in Win XP).

But I thought that it would be possible that e.g. a c# app is allowed to write inside it's own exe-directory or it's subfolders at least (not everything is 'user settings' or should be written to "MyDocuments"...).

So currently my c# app throws an UnauthorizedAccessException when trying to write inside the exe dir.

Is there anything you can do in c# code to allow writing inside the exe dir?

like image 943
fritz Avatar asked Feb 28 '23 05:02

fritz


1 Answers

No, if the user your application is running under doesn't have permissions to write to this folder you cannot write to it. When installing your application (probably through an MSI) you could grant the necessary rights.

You could also provide a manifest file with your application.

like image 57
Darin Dimitrov Avatar answered Mar 06 '23 22:03

Darin Dimitrov