To retrieve the DateDeleted
property of an Item is simple as this:
Private Sub Test() Handles MyBase.Shown
' Get all the desired deleted items inside the Recycle Bin using WindowsAPICodePack.
' ( In my case I only retrieve the deleted files excluding folders. )
Dim RecycledFiles As ShellFile() = RecycleBin.MasterBin.Files
' Loop through the deleted Items.
For Each Item As ShellFile In RecycledFiles
' Append the full name
sb.AppendLine(Item.Name)
' Append the DateDeleted.
sb.AppendLine(Item.Properties.GetProperty("DateDeleted").ValueAsObject.ToString)
MsgBox(sb.ToString)
sb.Clear()
Next Item
End Sub
Then to retrieve the last deleted file forexample:
''' <summary>
''' Gets the last deleted file inside recycle bin.
''' </summary>
''' <returns>ShellFile.</returns>
Public Shared Function GetLastDeletedFile() As ShellFile
Return (From Item As ShellFile In GetDeletedItems(Of ShellFile)(Nothing)
Order By Item.Properties.GetProperty("DateDeleted").ValueAsObject).Last
End Function
And with this snippet we can retrieve the other property names and values of each:
Dim sb As New System.Text.StringBuilder
Private Sub Test() Handles MyBase.Shown
' Get all the desired deleted items inside the Recycle Bin using WindowsAPICodePack.
' ( In my case I only retrieve the deleted files excluding folders. )
Dim RecycledFiles As ShellFile() = RecycleBin.MasterBin.Files
' Loop through the deleted Items.
For Each Item As ShellFile In RecycledFiles
' Append the full name (It's String type)
sb.AppendLine(Item.Name)
' Loop through the Item properties.
For Each prop In Item.Properties.DefaultPropertyCollection
' Append an empty line
sb.AppendLine()
' Append the property name (It's String type)
sb.Append(prop.CanonicalName)
' Append the property value (It's a generic Object type)
If prop.ValueAsObject IsNot Nothing Then
sb.Append(" = " & prop.ValueAsObject.ToString)
Else
sb.Append(" = NULL")
End If
MsgBox(sb.ToString)
Next prop
Next Item
End Sub
Just another example:
Private Sub Test() Handles MyBase.Shown
' Get all the deleted items inside the Recycle Bin using WindowsAPICodePack.
Dim RecycledItems As ShellObject() = RecycleBin.MainBin.Items
' Loop through the deleted Items (Ordered by Deletion Date).
For Each Item As ShellFile In (From itm In RecycledItems
Order By itm.Properties.GetProperty("DateDeleted").ValueAsObject Ascending)
' Append the property bags information.
sb.AppendLine(String.Format("Full Name: {0}",
Item.Name))
sb.AppendLine(String.Format("Item Name: {0}",
Item.Properties.GetProperty("System.ItemNameDisplay").ValueAsObject))
sb.AppendLine(String.Format("Deleted From: {0}",
Item.Properties.GetProperty("DeletedFrom").ValueAsObject))
sb.AppendLine(String.Format("Item Type: {0}",
Item.Properties.GetProperty("System.ItemTypeText").ValueAsObject))
sb.AppendLine(String.Format("Item Size: {0}",
Item.Properties.GetProperty("System.Size").ValueAsObject))
sb.AppendLine(String.Format("Attributes: {0}",
[Enum].Parse(GetType(IO.FileAttributes),
Item.Properties.GetProperty("System.FileAttributes").ValueAsObject.ToString)))
sb.AppendLine(String.Format("Date Deleted: {0}",
Item.Properties.GetProperty("DateDeleted").ValueAsObject))
sb.AppendLine(String.Format("Date Modified: {0}",
Item.Properties.GetProperty("System.DateModified").ValueAsObject))
sb.AppendLine(String.Format("Date Created: {0}",
Item.Properties.GetProperty("System.DateCreated").ValueAsObject))
MsgBox(sb.ToString)
sb.Clear()
Next Item
End Sub