2

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
4

2 に答える 2

2

DateDeletedItem のプロパティを取得するには、次のように簡単です。

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

次に、最後に削除されたファイルを取得するには、次のようにします。

''' <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

このスニペットを使用すると、他のプロパティ名とそれぞれの値を取得できます。

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

ちょうど別の例:

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
于 2014-01-17T18:59:27.897 に答える
2

Windows API Code Packが役に立つかもしれません。ほとんどのシェル インターフェイスのより広範な (完全な) 実装があります。コード パック アイテム (InternalsVisibleTo アプリケーション マニフェスト属性、または単にすべての内部インターフェイスを外部に変更する) を開いて、特定のラッパーからそれらを使用する必要があります。

削除日については、シェルアイテムのプロパティバッグに記載されています。マイクロソフトの初期から開発者であり、個人的に Windows シェルを生み出した偉大なレイモンド チェンは、C++ でそれを行う方法
について完全なウォークスルー記事を書きました。ごみ箱のアイテムについて? '

少し論理的に推測するだけで、必要な部分を取り除いて、独自のマネージ実装を作成できます。

これらの 2 つのリンクの間に、問題を解決するためのすべての知識といくつかの知識があります。

于 2014-01-07T19:17:25.393 に答える