Click here to Skip to main content
15,902,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a folder named ErrorLog in Program files (where my application is going to be installed) and

But I am not able to create folder in Program file, Access is denied error fires.

Please help me

[edit]Urgency removed, spurious code blocks removed - OriginalGriff[/edit]
Posted
Updated 28-Feb-11 22:11pm
v3

It is a permissions problem: you do not nhave permission to access folders under Prorgam Files - and for good reason.

Instead, put your log files in the Application Data folder. (there is also the Windows/System32/Logfiles folder, but I am not sure what permissions you will need for that one...)
 
Share this answer
 
Comments
Hesmsys 1-Mar-11 4:49am    
Yes, but I have a situation where I have to create a folder in program files. So please help me
Sergey Alexandrovich Kryukov 1-Mar-11 12:37pm    
No, you don't have that situation, because if you don't have this permission, this is for a good reason. You should use right place in your file system. Do what John advised.
--SA
Sergey Alexandrovich Kryukov 1-Mar-11 12:37pm    
"For a good reason" is the key, my 5.
--SA
Windows Vista (and later) will not allow you to write files to the Program Files folder without admin permissions. Get used to the idea, and change your requirements.

The proper place to save data files is in the appropriate special folder:

System.Environment.SpecialFolder on MSDN[^]

I recommend that you use LocalApplicationData to save the log file.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Mar-11 12:37pm    
This and only this way. My 5.
--SA
Hesmsys 2-Mar-11 4:09am    
But I have a situation, or else can we able to add user with full access rights so he can able to create a folder in program files
#realJSOP 2-Mar-11 5:16am    
Yeah, I guess you could, but that's ill-advised. I can't think of any situation that would warrant that, though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900