4

I would like to get the path to recycle bin. I searched online and found people use shell32 and get a list of files in recycle bin. However, I only want to get the path of recycle bin since my purpose is to exclude monitor recycle bin from my filewatcher when setting IncludeSubdirectories to true. The code using shell32 to get a list of files shown in the following, but I don't to how to get the path to recycle bin.

Shell Shl = new Shell();
Folder Recycler = Shl.NameSpace(10);
for (int i = 0; i < Recycler.Items().Count; i++)
{
    FolderItem FI = Recycler.Items().Item(i);
    string FileName = Recycler.GetDetailsOf(FI, 0);
    if (Path.GetExtension(FileName) == "") FileName += Path.GetExtension(FI.Path);
    string FilePath = Recycler.GetDetailsOf(FI, 1);
    Console.WriteLine(FilePath);
}

Thanks in advance!

Zong
  • 6,160
  • 5
  • 32
  • 46
bunny
  • 1,797
  • 8
  • 29
  • 58

3 Answers3

3

I had a server bogged down with over 590,000 files in the Recycle Bin. Any attempt to open the recycle bin caused the server to run out of memory and crash.

This code worked from Powershell ISE. It took almost 30 minutes. No errors.

Get-ChildItem -Path 'C:\$Recycle.Bin' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue
txgeekgirl
  • 31
  • 4
1

here is the recycle bin directory C:\$Recycle.Bin...if you want to get the files un-hide the diretory...

Noctis
  • 11,507
  • 3
  • 43
  • 82
HackerMan
  • 904
  • 7
  • 11
  • 2
    Does all recycle bin under C:\$Recycle.Bin all windows operating system? – bunny Apr 08 '14 at 14:09
  • 2
    I have heard that there is a recycle bin in each disk. Thus, if I have E or D drive, should I need to mention D:\$Recycle.Bin and E:\$Recycle.Bin? – bunny Apr 08 '14 at 14:25
-2

Please check this link. This may help you to get the path to recycle bin.

Here you can access the URL C:\$Recycle.Bin

Noctis
  • 11,507
  • 3
  • 43
  • 82
Tharindu Welagedara
  • 2,660
  • 18
  • 27