Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Files.App/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ public static class UserEnvironmentPaths

public static readonly string RecentItemsPath = Environment.GetFolderPath(Environment.SpecialFolder.Recent);

public static readonly string SystemDrivePath;

static UserEnvironmentPaths()
{
var systemDrive = Environment.GetEnvironmentVariable("SystemDrive");
SystemDrivePath = !string.IsNullOrEmpty(systemDrive) ? systemDrive : "C:";
}

public static Dictionary<string, string> ShellPlaces =
new()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Items/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static async Task<DriveItem> CreateFromPropertiesAsync(StorageFolder root
IsLocationItem = true,
ShowEjectDevice = item.IsRemovable,
ShowShellItems = true,
ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase)),
ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)),
ShowProperties = true
};
item.Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Services/Storage/StorageDevicesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()

public async Task<ILocatableFolder> GetPrimaryDriveAsync()
{
string cDrivePath = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\";
string cDrivePath = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\";
return new WindowsStorageFolder(await StorageFolder.GetFolderFromPathAsync(cDrivePath));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override async IAsyncEnumerable<ICloudProvider> GetProviders()
string syncFolder = inner.GetProperty("filespaceName").GetString();

string[] orgNameFilespaceName = syncFolder.Split(".");
string path = Path.Combine($@"{Environment.GetEnvironmentVariable("SystemDrive")}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]);
string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]);
string filespaceName = orgNameFilespaceName[0];

string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico");
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Utils/Shell/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public async Task<bool> InvokeItem(int itemID)

public static async Task WarmUpQueryContextMenuAsync()
{
using var cMenu = await GetContextMenuForFiles(new string[] { $@"{Environment.GetEnvironmentVariable("SystemDrive")}\" }, Shell32.CMF.CMF_NORMAL);
using var cMenu = await GetContextMenuForFiles(new string[] { $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\" }, Shell32.CMF.CMF_NORMAL);
}

private void EnumMenuItems(HMENU hMenu, List<Win32ContextMenuItem> menuItemsResult, bool loadSubenus = false)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class StorageSenseHelper
{
public static async Task OpenStorageSenseAsync(string path)
{
if (!path.StartsWith(Environment.GetEnvironmentVariable("SystemDrive"), StringComparison.OrdinalIgnoreCase)
if (!path.StartsWith(Constants.UserEnvironmentPaths.SystemDrivePath, StringComparison.OrdinalIgnoreCase)
&& ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
{
LaunchHelper.LaunchSettings("page=SettingsPageStorageSenseStorageOverview&target=SystemSettings_StorageSense_VolumeListLink");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class CreateShortcutDialogViewModel : ObservableObject
public readonly string WorkingDirectory;

// Placeholder text of destination path textbox
public readonly string DestinationPlaceholder = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\Users\";
public readonly string DestinationPlaceholder = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Users\";

// Tells whether destination path exists
public bool DestinationPathExists { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/ViewModels/Properties/BasePropertiesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
BaseProperties = props;

ViewModel.CleanupVisibility = props.Drive.Type != DriveType.Network;
ViewModel.FormatVisibility = !(props.Drive.Type == DriveType.Network || string.Equals(props.Drive.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase));
ViewModel.FormatVisibility = !(props.Drive.Type == DriveType.Network || string.Equals(props.Drive.Path, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase));
ViewModel.CleanupDriveCommand = new AsyncRelayCommand(() => StorageSenseHelper.OpenStorageSenseAsync(props.Drive.Path));
ViewModel.FormatDriveCommand = new RelayCommand(async () =>
{
Expand Down