Q:

How to create a directory in C directory of Windows7 in C#.Net

I am writing the exception log (eg.  log.txt) and I want to write in the following path "C:\Program Files (x86)\App\Log".  When I do so, I get the whole path as access denied which means I cannot create the folder called Log and simultaneously write the log.txt and I have also the compression code to zip the log files like log.zip which is a days based?  I did try some of the code snippets from the stack overflow apparently nothing fruitful. 
How do I resolve this problem?? 
Regards,
Gibson

A:

The error you are getting is most likely due to the fact that a regular user doesn't have permission to create folders or files beneath the "C:\Program Files (x86)\" directory.   This is on purpose because a regular user should not be writing to that directory. 
Applications are installed beneath that directory by an administrative user, or a user with elevated permissions.   Your application should be writing log files to a location beneath the user's profile directory, e.g. somewhere beneath "%appdata%". 
I work in an IT department where we have to support poorly-written vendor software that needs to update files somewhere beneath the %programfiles% directory, and it's a total nightmare.   We don't want our users to have permission in general to write to that folder because it would potentially allow malicious software -- viruses, etc. --  to surreptitiously modify our applications.   However, we have to make exceptions in our virus software and constantly maintain special security on the folders for this deviant application that, unfortunately, our business relies on.   The point of the story is: don't do it.   It's bad practice, and your customers will not be happy.