你需要参考:
using Shell32;
代码:
var shl = new Shell();
// Get recycle folder
Folder recycler = shl.NameSpace(10);
FolderItems items = recycler.Items();
for (int i = 0; i < items.Count; i++)
{
try
{
FolderItem fi = items.Item(i);
string fileName = recycler.GetDetailsOf(fi, 0);
string filePath = recycler.GetDetailsOf(fi, 1);
string recyleDate = recycler.GetDetailsOf(fi, 2);
if (fileName == "your file/folder")
{
// check if chosen item is a folder
if (fi.IsFolder)
{
Directory.Delete(fi.Path, true);
}
else
{
File.Delete(fi.Path);
}
}
}
catch (Exception exc)
{
...
}
}
希望这可能会有所帮助。为我工作。