Search code examples
.netvb.netwinformsrecycle-binwindows-api-code-pack

How to retrieve the 'Deletion Date' property of an Item stored in the Recycle Bin using Windows API Code Pack?


UPDATE 2

Finally testing most of the WindowsAPICodePack interfaces I've found bymyself the way to acces to the deleted Files on the RecycleBin.

The unique problem now is that I need to know how to acces the required property bag to retrieve the deletion date of each file (and folder and link), This is a sample code:

Dim RecycleBin As IKnownFolder = KnownFolders.RecycleBin

For Each File As ShellFile In (From Item As ShellObject In RecycleBin
                               Where Item.GetType = GetType(ShellFile))

    MsgBox(File.Name)
    MsgBox(File.Properties.System.IsDeleted.Value) ' It's empty.
    MsgBox(File.Properties.System.DateAcquired.Value) ' This is not the correct value.
    MsgBox(File.Properties.System.DateArchived.Value) ' This is also not the correct value.
    MsgBox(File.Properties.System.DateCompleted.Value) ' This is also not the correct value.
    MsgBox(File.Properties.System.DateCreated.Value) ' This is also not the correct value.
    MsgBox(File.Properties.System.DateImported.Value) ' This is also not the correct value.

Next File

Solution

  • The Windows API Code Pack might be of some help to you. It has more extensive (full) implementations of most shell interfaces. You will have to open up the code pack items (InternalsVisibleTo application manifest attribute, or just change all the internal interfaces to external) in order to use them away from the given wrappers.

    As for the delete date: That's contained in the property bag of the shell item.
    The great Raymond Chen, who has been a developer at Microsoft since the beginning of time and personally gave birth to the Windows Shell wrote a complete walk-through article about how to go about doing it in C++, aptly named 'How can I get information about the items in the Recycle Bin?'

    You can, with a little bit of logical deduction, take the bits you need away from it and produce your own managed implementation.

    Between those two links, you now have all the knowledge in your possession to solve your problem and then some.