Access denied, file/folder audit... c# vs2012

Posted on 2014-12-25
Last Modified: 2015-01-10
I have produced small application using which functions well for certain folders but not all.

It works well for path like: C:\Users\Public\Documents\UntypeDatasetSample which there is no security requirements. But it doesn't work for most other folders because the security issues discussed at:

Question: Is it possible to dynamically pacify the security and reinstate it after the files and folders have been audited?

If you wish to have a copy of this 60KB applcation, download it from:
Question by:Mike Eghtebas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40518081
What happens if you right-click on the program name and select "Run as Administrator"?
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40518083
I am running as admin. It errors as shown below:
Above and beyond admin sign-in, the following link below seems to suggest the need to change security for folders being accessed.

Public folder doesn't have security but My Music folder (by default) has in windows 7.

LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40518087
On Windows 7, your user, even when an Admin, does not run with Admin privileges most of the time.  Many times when I have to install programs on Windows 7, I have to right-click and select "Run as Administrator" even though the user is the Only user and is an Administrator.  But then... I knew you wouldn't try it.
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

LVL 34

Author Comment

by:Mike Eghtebas
ID: 40518095
As you are describing, I have too, to use run as admin when it is needed. This application is for learning at this point. As we know users will not have admin rights and that is good (they will not be able to view the content of certain folders they are not allowed to). But as admin, I do not want to manually change each and every folder just to audit them and then go back to restore their security. I am hoping for a dynamic solution.
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40518129
Yes... but did you try "Run as Admin" to see if the program you are working on works in your 'admin' account?  I doubt that you will find "a dynamic solution", especially for regular non-admin users.
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40518146
re:> but did you try "Run as Admin" to see if the program you are working on works in your 'admin' account?
A folder is nothing to run as. I am able open My Music folder manually but the code I am running, is not able to open it to read its content despite the fact I have logged as admin prior to running  this code.

re: especially for regular non-admin users
This is good, because non-admin users are better to be limited to only the folders they are allowed to view.

re:> I doubt that you will find "a dynamic solution"
All I can do is to keep asking around. I think, I better include some other TAs such as operating system or those heavily involved with security issues.
LVL 83

Accepted Solution

CodeCruiser earned 400 total points
ID: 40526215
First, as suggested, try to run the app as admin to ensure that the problem you are having is due to admin access requirement. If it is the case then you will need to impersonate an admin user as shown in examples

For asking current user to elevate UAC level, see examples

You can only access folders that the current user has access while you are running as that user. If you need to access the folders that current user does not have access to, you need to either give permissions or run as a different user that has permissions. There is no other way (and should not be any other way).

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question