1

Been a lurker for a long time, first post. So just let me know what I need to do if I'm unclear, not enough information, etc.

System: Windows 7 VS2012 C#

Trying to just run the code from here, first method: http://msdn.microsoft.com/en-us/library/bb546133.aspx

And it works as is for any file within my user directory, but not the user directory itself. C:\Users\me\dir not C:\Users\me or up. Getting System.UnauthorizedAccessException on C:\documents and settings

Looking around, most posts I found said to just

static void QueryDuplicates()
    {
      try
      { //Query for Duplicates }
      catch {//left blank}
    }

Which I think is insecure so I tired:

catch (Exceptions ex)
{
if {ex is System.UnauthorizedAccessException} {} 
else {Console.writeline(ex.message);}
}

which I guess is a little better :-(

That bypasses the original error but now I get "A first chance exception of type 'System.UnauthorizedAccessException'occured in mscorlib.dll" I find this odd because shouldn't this have been skipped over?

The best I've found is to make a manifest, but I'd rather not be skipping errors and then forcing a program to run as admin. Seems really insecure and a bandaid solution.

http://blogs.msdn.com/b/nikhiln/archive/2007/04/19/embed-a-manifest-to-make-an-application-elevate-in-vista.aspx

The end result I'm looking for is to loop through a whole drive and find all the duplicate files. At least this is the first step in the program I'm writing. I'm looking for either a better solution than what I'm trying, a true fix for the issues, or anything to try.

2
  • The only solution which I'm aware is the link which you post. Oct 7, 2014 at 2:44
  • Have you ever used it?
    – Joe
    Oct 8, 2014 at 2:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.