mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
* Peek support for special folders * Renamed ThisComputer->ThisPC * Used different variable name to avoid spellcheck issues * Made label of empty fields hidden * Removed ThisPC special handling and last modified date of recycle bin
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using ManagedCommon;
|
|
using Windows.Storage;
|
|
|
|
#nullable enable
|
|
|
|
namespace Peek.Common.Models
|
|
{
|
|
public class FolderItem(string path, string name, string parsingName) : IFileSystemItem
|
|
{
|
|
private StorageFolder? storageFolder;
|
|
|
|
public string Name { get; init; } = name;
|
|
|
|
public string ParsingName { get; init; } = parsingName;
|
|
|
|
public string Path { get; init; } = path;
|
|
|
|
public string Extension => string.Empty;
|
|
|
|
public async Task<IStorageItem?> GetStorageItemAsync()
|
|
{
|
|
return await GetStorageFolderAsync();
|
|
}
|
|
|
|
public async Task<StorageFolder?> GetStorageFolderAsync()
|
|
{
|
|
if (storageFolder == null)
|
|
{
|
|
try
|
|
{
|
|
storageFolder = string.IsNullOrEmpty(Path) ? null : await StorageFolder.GetFolderFromPathAsync(Path);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError("Error getting folder from path. " + ex.Message);
|
|
storageFolder = null;
|
|
}
|
|
}
|
|
|
|
return storageFolder;
|
|
}
|
|
}
|
|
}
|