From b31d35c456bbde96f2871aceaa8a9accb1a80fea Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Tue, 24 Jan 2017 10:59:26 -0800 Subject: [PATCH 1/2] Add an IsFolder method to FileOrFolderInformation class. --- .../Core/AppFileExplorer.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs index 0b155fc9..1ae2e676 100644 --- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs +++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs @@ -310,6 +310,11 @@ public class FileOrFolderInformation [DataMember(Name = "FileSize")] public long SizeInBytes { get; private set; } + /// + /// Gets whether the current item is a folder + /// + public bool IsFolder { get { return this.Type == 0x10; } } + /// /// Overridden ToString method providing a user readable /// display of a file or folder. Tries to match the formatting @@ -321,7 +326,7 @@ public override string ToString() DateTime timestamp = DateTime.FromFileTime(this.DateCreated); // Check if this is a folder. - if (!string.Equals(this.SubPath, this.CurrentDir)) + if (this.IsFolder) { return string.Format("{0,-24:MM/dd/yyyy HH:mm tt}{1,-14} {2}\n", timestamp, "", this.Name); } From b09f98c61bc22ec0187baac70c3841a3d78f0d1b Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Tue, 24 Jan 2017 11:42:24 -0800 Subject: [PATCH 2/2] Updated per review feedback --- .../Core/AppFileExplorer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs index 1ae2e676..e4b31f3e 100644 --- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs +++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs @@ -311,9 +311,10 @@ public class FileOrFolderInformation public long SizeInBytes { get; private set; } /// - /// Gets whether the current item is a folder + /// Gets whether the current item is a folder by checking for FILE_ATTRIBUTE_DIRECTORY + /// See https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx /// - public bool IsFolder { get { return this.Type == 0x10; } } + public bool IsFolder { get { return (this.Type & 0x10) == 0x10; } } /// /// Overridden ToString method providing a user readable