I'm working on a winform application which creates directories and copies files to the user's local machine at runtime.
My question is:
Can my application create and copy files to the user's local machine even if he doesn't have administrative privileges? If not, how can I do that?
Thanks
EDIT: I'm asking because a user complained that some files weren't copied to his HD.
Asked
Active
Viewed 403 times
0

FadelMS
- 2,027
- 5
- 25
- 42
-
1Have you tried? There are some locations you can freely write to. Program directories - most likely not by default ...you would have to use security attributes to impersonate an administrator (I believe). Haven't done this myself ...yet. ;) – IAbstract Jul 31 '12 at 23:58
-
possible duplicate of [How to force C# App to run as administrator on Windows 7](http://stackoverflow.com/questions/2818179/how-to-force-c-sharp-app-to-run-as-administrator-on-windows-7) – Hans Passant Aug 01 '12 at 00:19
2 Answers
0
You need elevated permissions only to copy to certain protected areas. This especially caused problems when Vista was introduced because programs used to maintaining data in the folder they were installed (e.g. and ini file) would no longer work with default permission settings.
Have a look at Environment.SpecialFolders
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
especially at the CommonApplicationData location.
It is wise to store your program data in a subfolder from that or a similar location intended for program specific storage.

Eric J.
- 147,927
- 63
- 340
- 553
-
What if choosing a folder is left to the user himself. My application asks the user to choose a folder to save these files. – FadelMS Aug 01 '12 at 00:12
-
If a directory is not writable, can I change its attributes and make it writable? – FadelMS Aug 01 '12 at 00:18
-
Probably not. Security is generally dictated by permissions rather than read/write attributes on the directory (one can mark a directory read-only, but that is very uncommon in the Windows world). – Eric J. Aug 01 '12 at 04:16
0
You can do anything you said.
But you need to give admin rights to your application.

Fahim Parkar
- 30,974
- 45
- 160
- 276

seokrae.kim
- 304
- 3
- 9