MethodManX
MethodManX

Reputation: 999

Access Denied error in while searching for files

i get the following error when i try to search for files in c:\ directory..

Access to the path 'C:\$RECYCLE.BIN\S-1-5-21-3560828095-1020290111-2102031911-500' is denied.

The code im using is:

private void button12_Click(object sender, EventArgs e)
    {

        string[] files = Directory.GetFiles("C:\\",
      "*.*",
      SearchOption.AllDirectories);

        // Display all the files.
        foreach (string file in files)
        {
            MessageBox.Show(file);
        }

    }

`

Upvotes: 0

Views: 522

Answers (1)

Marc B
Marc B

Reputation: 360792

And this is a problem... how? The recycle bin subdirectories are owned by the individual users on your machine and the account you're running this from is attempting to access some OTHER account's recycle bin.

Upvotes: 1

Related Questions