I am working on homework to get the file count of the recycle bin by using shell32.dll. However, I am struggling to display the list of the files in the recycle bin and keep getting a System.InvalidCastException
error when I try to use the shell.
I have browsed for quite a few solutions on Stack Overflow, and most of them used shell32.dll to get the files list of the recycle bin.
The latest code I've tried is as below:
public static void Main(string[] args)
{
Shell shell = new Shell();
Folder folder = shell.NameSpace(0x000a);
foreach (FolderItem2 item in folder.Items())
Console.WriteLine("FileName:{0}", item.Name);
Marshal.FinalReleaseComObject(shell);
Console.ReadLine();
}