Hi i have a application that creat/write a Logfile (later it will write a ErrorLog)
but at the moment i stick in to the permission problem because if the user havn’t the right to creat a File in the Folder where my app is it throws an exeption
now my question how do i get indipendent (from the user) creating and writing rights for this app
i read this but it doesn’t help because the client won’t be able to give that permissions
(they are not authorized) but i need that right for my app
your help will appreciated
It’s a common conception (I would even say, a best practice) to have the program binaries separated from its data.
All Windows app, for example, are located under
Program files, but write their data either under user’s%APPDATA%for personal data or%ProgramData%for shared data. You should follow this guidelines, unless your program have very specific requirements.Depending on the kind of data, especially if you want the user to find quickly the data, you can also create a subfolder under user’s document folder.
Using C#, you will be able to find easily of this special folders using Environment.GetFolderPath Method. For example:
If you look at the Environment.SpecialFolderOption Enumeration, you will see that most of the common places are easily be found.
As you stated the data will be shared by all users, you should specifically targets
%ProgramData%, which is found by usingEnvironment.SpecialFolder.CommonApplicationData:Ultimately, this folder will be resolved as (with default settings)
C:\Programdata\MyApplication.