Last active
November 27, 2019 14:18
-
-
Save Sheepings/9d49ded6ae433beb814671956d3b8279 to your computer and use it in GitHub Desktop.
Iterate Recycle bin objects and return paths patterns names and addresses to a List<Tuple<string, string, string>>. Requires a reference to shell32.dll in system32 folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Tuple<string, string, string>> rBinFiles = new List<Tuple<string, string, string>>(); | |
private void Button1_Click(object sender, EventArgs e) | |
{ | |
var recycleBin = @"C:\$Recycle.Bin"; | |
DirectoryInfo rBinInfo = new DirectoryInfo(recycleBin); | |
GetBinFileNames(); | |
foreach (List<Tuple<string, string, string>> t in GetBinFileNames()) | |
{ | |
t.ForEach((Tuple<string, string, string> name) => | |
{ | |
Debug.WriteLine($"Original File Name : {name.Item1}"); | |
Debug.WriteLine($"File Name Pattern : {name.Item3}"); | |
Debug.WriteLine($"Path Pattern : {name.Item2}"); | |
}); | |
} | |
} | |
public IEnumerable<List<Tuple<string, string, string>>> GetBinFileNames() | |
{ | |
Shell s = new Shell(); | |
Folder rBin = s.NameSpace(10); | |
foreach (FolderItem2 fBin in rBin.Items()) | |
{ | |
rBinFiles.Add(Tuple.Create(fBin.Name, fBin.Path, Path.GetFileName(fBin.Path))); | |
yield return rBinFiles; | |
} | |
Marshal.FinalReleaseComObject(s); | |
yield return rBinFiles; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment