How can I get path to recycle bin?

2019-02-19 12:19发布

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!

2条回答
等我变得足够好
2楼-- · 2019-02-19 12:56

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

查看更多
神经病院院长
3楼-- · 2019-02-19 13:08

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

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

查看更多
登录 后发表回答