4

我想获得回收站的路径。我在网上搜索,发现人们使用 shell32 并在回收站中获取文件列表。但是,我只想获取回收站的路径,因为我的目的是在将 IncludeSubdirectories 设置为 true 时从我的文件观察器中排除监视器回收站。使用shell32获取文件列表的代码如下所示,但我不知道如何获取回收站的路径。

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);
}

提前致谢!

4

3 回答 3

3

我的服务器陷入了回收站中超过 590,000 个文件的困境。任何打开回收站的尝试都会导致服务器内存不足并崩溃。

此代码适用于 Powershell ISE。花了将近30分钟。没有错误。

Get-ChildItem -Path 'C:\$Recycle.Bin' -Force | Remove-Item -Recurse -ErrorAction SilentlyContinue
于 2019-08-01T21:45:27.857 回答
1

这是回收站目录C:\$Recycle.Bin...如果您想获取目录中的文件un-hide...

于 2014-04-06T08:02:14.143 回答
-2

请检查链接。这可以帮助您找到回收站的路径。

在这里您可以访问网址C:\$Recycle.Bin

于 2014-04-08T08:16:09.827 回答