From 3085b7d41228b0c2a821b0afa3b314f1fe9ec461 Mon Sep 17 00:00:00 2001 From: dahall Date: Mon, 31 Aug 2020 10:43:21 -0600 Subject: [PATCH] Added new property keys for Recycle Bin (#162) --- PInvoke/Ole/Ole32/WTypes.PROPERTYKEY.cs | 22 ++++++++++++++++++++++ UnitTests/Windows.Shell/RecycleBinTests.cs | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/PInvoke/Ole/Ole32/WTypes.PROPERTYKEY.cs b/PInvoke/Ole/Ole32/WTypes.PROPERTYKEY.cs index 302d64be..69faae32 100644 --- a/PInvoke/Ole/Ole32/WTypes.PROPERTYKEY.cs +++ b/PInvoke/Ole/Ole32/WTypes.PROPERTYKEY.cs @@ -6300,6 +6300,28 @@ namespace Vanara.PInvoke => new PROPERTYKEY(new Guid("{1B5439E7-EBA1-4AF8-BDD7-7AF1D4549493}"), 100); } + /// Recycle Bin Properties + public static class Recycle + { + /// + /// Name: System.Recycle.DeletedFrom + /// Description: Location (path) the file in the Recycle Bin was deleted from. + /// Type: String -- VT_LPWSTR (For variants: VT_BSTR) + /// FormatID: {9b174b33-40ff-11d2-a27e-00c04fc30871}, 2 + /// + public static PROPERTYKEY DeletedFrom + => new PROPERTYKEY(new Guid("{9b174b33-40ff-11d2-a27e-00c04fc30871}"), 2); + + /// + /// Name: System.Recycle.DateDeleted + /// Description: Location (path) the file in the Recycle Bin was deleted from. + /// Type: DateTime -- VT_FILETIME (For variants: VT_DATE) + /// FormatID: {9b174b33-40ff-11d2-a27e-00c04fc30871}, 3 + /// + public static PROPERTYKEY DateDeleted + => new PROPERTYKEY(new Guid("{9b174b33-40ff-11d2-a27e-00c04fc30871}"), 3); + } + /// Search Properties public static class Search { diff --git a/UnitTests/Windows.Shell/RecycleBinTests.cs b/UnitTests/Windows.Shell/RecycleBinTests.cs index e76c7897..4bbb83ac 100644 --- a/UnitTests/Windows.Shell/RecycleBinTests.cs +++ b/UnitTests/Windows.Shell/RecycleBinTests.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using Vanara.Extensions; using Vanara.InteropServices; using Vanara.PInvoke; using Vanara.PInvoke.Tests; @@ -32,13 +33,15 @@ namespace Vanara.Windows.Shell.Tests try { + var startCount = RecycleBin.Count; // Delete files to bin RecycleBin.DeleteToRecycleBin(paths, true); // Get details TestContext.WriteLine($"cnt={RecycleBin.Count}; sz={RecycleBin.Size}"); + Assert.That(RecycleBin.Count, Is.EqualTo(startCount + paths.Count)); // Restore files RecycleBin.Restore(paths.Select(p => RecycleBin.GetItemFromOriginalPath(p))); - Assert.That(RecycleBin.Count, Is.EqualTo(0L)); + Assert.That(RecycleBin.Count, Is.EqualTo(startCount)); } finally {