From 583e7b2d6146016edc642dbe54172c2ffe010887 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:08:53 -0400 Subject: [PATCH 01/13] Revert "Code Quality: Update dependencies (#15810)" This reverts commit b2066406575f637ab6250692833f2c4e3c067ff0. --- src/Files.App (Package)/Files.Package.wapproj | 2 +- .../Files.App.BackgroundTasks.csproj | 2 +- src/Files.App.Controls/Files.App.Controls.csproj | 4 ++-- src/Files.App.Server/Files.App.Server.csproj | 2 +- src/Files.App/Files.App.csproj | 8 ++++---- src/Files.Shared/Files.Shared.csproj | 2 +- tests/Files.App.UITests/Files.App.UITests.csproj | 2 +- .../Files.InteractionTests/Files.InteractionTests.csproj | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Files.App (Package)/Files.Package.wapproj b/src/Files.App (Package)/Files.Package.wapproj index 37c1cce34459..ecd9c6ab3ffd 100644 --- a/src/Files.App (Package)/Files.Package.wapproj +++ b/src/Files.App (Package)/Files.Package.wapproj @@ -107,7 +107,7 @@ - + diff --git a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj index bc79f3d79537..297b1bc9976c 100644 --- a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj +++ b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index 1be6e0d8325e..f222efed7434 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/Files.App.Server/Files.App.Server.csproj b/src/Files.App.Server/Files.App.Server.csproj index 3a5bcc6e9271..89c1fc9b757a 100644 --- a/src/Files.App.Server/Files.App.Server.csproj +++ b/src/Files.App.Server/Files.App.Server.csproj @@ -39,7 +39,7 @@ - + diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index 3dd0139ad92a..d73ab03500a2 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -71,15 +71,15 @@ - + - + - + @@ -91,7 +91,7 @@ - + diff --git a/src/Files.Shared/Files.Shared.csproj b/src/Files.Shared/Files.Shared.csproj index d3611aa761f7..30954645ae4e 100644 --- a/src/Files.Shared/Files.Shared.csproj +++ b/src/Files.Shared/Files.Shared.csproj @@ -21,7 +21,7 @@ - + diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index 94198bb15af7..e3aafa619a96 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -20,7 +20,7 @@ - + diff --git a/tests/Files.InteractionTests/Files.InteractionTests.csproj b/tests/Files.InteractionTests/Files.InteractionTests.csproj index 58431406006a..f99d723fb0c3 100644 --- a/tests/Files.InteractionTests/Files.InteractionTests.csproj +++ b/tests/Files.InteractionTests/Files.InteractionTests.csproj @@ -21,8 +21,8 @@ - - + + From 7c7d14dc40d811cdbed46f40f4d000a3a157db44 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:08:59 -0400 Subject: [PATCH 02/13] Revert "Fix: Fixed FileNotFoundException in Recycle Bin watcher (#15808)" This reverts commit 8260de7f923fd744c9f84ffee62cd42865b686b9. --- .../Utils/RecycleBin/RecycleBinManager.cs | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs index 8b834a19747a..1a0548d6e2a1 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs @@ -51,21 +51,18 @@ private void StartRecycleBinWatcher() if (drive.DriveType == SystemIO.DriveType.Network || !SystemIO.Directory.Exists(recyclePath)) continue; - SafetyExtensions.IgnoreExceptions(() => + SystemIO.FileSystemWatcher watcher = new() { - SystemIO.FileSystemWatcher watcher = new() - { - Path = recyclePath, - Filter = "*.*", - NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName - }; - - watcher.Created += RecycleBinWatcher_Changed; - watcher.Deleted += RecycleBinWatcher_Changed; - watcher.EnableRaisingEvents = true; - - binWatchers.Add(watcher); - }); + Path = recyclePath, + Filter = "*.*", + NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName + }; + + watcher.Created += RecycleBinWatcher_Changed; + watcher.Deleted += RecycleBinWatcher_Changed; + watcher.EnableRaisingEvents = true; + + binWatchers.Add(watcher); } } From f588fa4e10886356e2871f184bc767017f09f140 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:09:19 -0400 Subject: [PATCH 03/13] Revert "Code Quality: Fallback to "C:\" when var doesn't work (#15842)" This reverts commit 277ccb0ccbaf98ebe8a4a649527a166b571ad6f7. --- src/Files.App/Constants.cs | 8 -------- src/Files.App/Data/Items/DriveItem.cs | 2 +- src/Files.App/Services/Storage/StorageDevicesService.cs | 2 +- .../Utils/Cloud/Detector/LucidLinkCloudDetector.cs | 2 +- src/Files.App/Utils/Shell/ContextMenu.cs | 2 +- src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs | 2 +- .../ViewModels/Dialogs/CreateShortcutDialogViewModel.cs | 2 +- src/Files.App/ViewModels/Properties/BasePropertiesPage.cs | 2 +- 8 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Files.App/Constants.cs b/src/Files.App/Constants.cs index eb71b9366eb5..46e4325eeea5 100644 --- a/src/Files.App/Constants.cs +++ b/src/Files.App/Constants.cs @@ -240,14 +240,6 @@ 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 ShellPlaces = new() { diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index 0168e683b839..6f74e7db8ee6 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -240,7 +240,7 @@ public static async Task CreateFromPropertiesAsync(StorageFolder root IsLocationItem = true, ShowEjectDevice = item.IsRemovable, ShowShellItems = true, - ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)), + ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase)), ShowProperties = true }; item.Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path; diff --git a/src/Files.App/Services/Storage/StorageDevicesService.cs b/src/Files.App/Services/Storage/StorageDevicesService.cs index e415b0a9fb09..a8b355b143ec 100644 --- a/src/Files.App/Services/Storage/StorageDevicesService.cs +++ b/src/Files.App/Services/Storage/StorageDevicesService.cs @@ -55,7 +55,7 @@ public async IAsyncEnumerable GetDrivesAsync() public async Task GetPrimaryDriveAsync() { - string cDrivePath = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\"; + string cDrivePath = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\"; return new WindowsStorageFolder(await StorageFolder.GetFolderFromPathAsync(cDrivePath)); } diff --git a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs index 74ccb39f5dcb..49a5f83a3224 100644 --- a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs @@ -28,7 +28,7 @@ protected override async IAsyncEnumerable GetProviders() string syncFolder = inner.GetProperty("filespaceName").GetString(); string[] orgNameFilespaceName = syncFolder.Split("."); - string path = Path.Combine($@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]); + string path = Path.Combine($@"{Environment.GetEnvironmentVariable("SystemDrive")}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]); string filespaceName = orgNameFilespaceName[0]; string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico"); diff --git a/src/Files.App/Utils/Shell/ContextMenu.cs b/src/Files.App/Utils/Shell/ContextMenu.cs index dbef74c3696c..01354324a24e 100644 --- a/src/Files.App/Utils/Shell/ContextMenu.cs +++ b/src/Files.App/Utils/Shell/ContextMenu.cs @@ -174,7 +174,7 @@ public async Task InvokeItem(int itemID) public static async Task WarmUpQueryContextMenuAsync() { - using var cMenu = await GetContextMenuForFiles(new string[] { $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\" }, Shell32.CMF.CMF_NORMAL); + using var cMenu = await GetContextMenuForFiles(new string[] { $@"{Environment.GetEnvironmentVariable("SystemDrive")}\" }, Shell32.CMF.CMF_NORMAL); } private void EnumMenuItems(HMENU hMenu, List menuItemsResult, bool loadSubenus = false) diff --git a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs index 4679ee851af2..0299f7570cba 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs @@ -10,7 +10,7 @@ internal sealed class StorageSenseHelper { public static async Task OpenStorageSenseAsync(string path) { - if (!path.StartsWith(Constants.UserEnvironmentPaths.SystemDrivePath, StringComparison.OrdinalIgnoreCase) + if (!path.StartsWith(Environment.GetEnvironmentVariable("SystemDrive"), StringComparison.OrdinalIgnoreCase) && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { LaunchHelper.LaunchSettings("page=SettingsPageStorageSenseStorageOverview&target=SystemSettings_StorageSense_VolumeListLink"); diff --git a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs index f8012b42c568..3ddfc8b8f7db 100644 --- a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs +++ b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs @@ -15,7 +15,7 @@ public sealed class CreateShortcutDialogViewModel : ObservableObject public readonly string WorkingDirectory; // Placeholder text of destination path textbox - public readonly string DestinationPlaceholder = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\Users\"; + public readonly string DestinationPlaceholder = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\Users\"; // Tells whether destination path exists public bool DestinationPathExists { get; set; } diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index 5524d9e5bc24..ab81ba6ece79 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -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, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)); + ViewModel.FormatVisibility = !(props.Drive.Type == DriveType.Network || string.Equals(props.Drive.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase)); ViewModel.CleanupDriveCommand = new AsyncRelayCommand(() => StorageSenseHelper.OpenStorageSenseAsync(props.Drive.Path)); ViewModel.FormatDriveCommand = new RelayCommand(async () => { From 647aa4bc70e90bd9512fb66d719130da02ee13f4 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:09:24 -0400 Subject: [PATCH 04/13] Revert "Code Quality: Use `%SYSTEMDRIVE%` environment variable instead of `C:` (#15805)" This reverts commit 38fe3fb0b1eca8bb25637175d4239eaa83c50c90. --- src/Files.App.Launcher/FilesLauncher.cpp | 2 +- src/Files.App.OpenDialog/FilesOpenDialog.cpp | 7 ++----- src/Files.App.SaveDialog/FilesSaveDialog.cpp | 7 ++----- src/Files.App/Data/Items/DriveItem.cs | 2 +- src/Files.App/Dialogs/CreateShortcutDialog.xaml | 2 +- src/Files.App/Services/Storage/StorageDevicesService.cs | 2 +- .../Utils/Cloud/Detector/LucidLinkCloudDetector.cs | 2 +- src/Files.App/Utils/Shell/ContextMenu.cs | 2 +- src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs | 2 +- .../ViewModels/Dialogs/CreateShortcutDialogViewModel.cs | 3 --- src/Files.App/ViewModels/Properties/BasePropertiesPage.cs | 2 +- tests/Files.InteractionTests/SessionManager.cs | 8 ++++---- 12 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/Files.App.Launcher/FilesLauncher.cpp b/src/Files.App.Launcher/FilesLauncher.cpp index 4873f8ee563a..dfe08e6e9170 100644 --- a/src/Files.App.Launcher/FilesLauncher.cpp +++ b/src/Files.App.Launcher/FilesLauncher.cpp @@ -65,7 +65,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine LocalFree(szArglist); WCHAR szBuf[MAX_PATH]; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); std::wcout << szBuf << std::endl; if (_waccess(szBuf, 0) == -1) { diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.cpp b/src/Files.App.OpenDialog/FilesOpenDialog.cpp index f1dec80b6568..5b0659fb8b25 100644 --- a/src/Files.App.OpenDialog/FilesOpenDialog.cpp +++ b/src/Files.App.OpenDialog/FilesOpenDialog.cpp @@ -21,10 +21,7 @@ using std::endl; CComPtr GetSystemDialog() { - WCHAR comdlg32Path[MAX_PATH]; - ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); - - HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); + HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false); BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); CComPtr pClassFactory; @@ -162,7 +159,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.cpp b/src/Files.App.SaveDialog/FilesSaveDialog.cpp index b17d018e78f9..b89c3e411105 100644 --- a/src/Files.App.SaveDialog/FilesSaveDialog.cpp +++ b/src/Files.App.SaveDialog/FilesSaveDialog.cpp @@ -20,10 +20,7 @@ using std::endl; CComPtr GetSystemDialog() { - WCHAR comdlg32Path[MAX_PATH]; - ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); - - HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); + HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false); BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); CComPtr pClassFactory; @@ -438,7 +435,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index 6f74e7db8ee6..a7668d8ff88c 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -240,7 +240,7 @@ public static async Task 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, "C:\\", StringComparison.OrdinalIgnoreCase)), ShowProperties = true }; item.Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path; diff --git a/src/Files.App/Dialogs/CreateShortcutDialog.xaml b/src/Files.App/Dialogs/CreateShortcutDialog.xaml index 554f53e5a24b..6fb503d885e9 100644 --- a/src/Files.App/Dialogs/CreateShortcutDialog.xaml +++ b/src/Files.App/Dialogs/CreateShortcutDialog.xaml @@ -50,7 +50,7 @@ Grid.Row="2" Grid.Column="0" HorizontalAlignment="Stretch" - PlaceholderText="{x:Bind ViewModel.DestinationPlaceholder, Mode=OneWay}" + PlaceholderText="C:\Users\" Text="{x:Bind ViewModel.DestinationItemPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> GetDrivesAsync() public async Task GetPrimaryDriveAsync() { - string cDrivePath = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\"; + string cDrivePath = @"C:\"; return new WindowsStorageFolder(await StorageFolder.GetFolderFromPathAsync(cDrivePath)); } diff --git a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs index 49a5f83a3224..92dbed1f8d98 100644 --- a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs @@ -28,7 +28,7 @@ protected override async IAsyncEnumerable 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(@"C:\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]); string filespaceName = orgNameFilespaceName[0]; string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico"); diff --git a/src/Files.App/Utils/Shell/ContextMenu.cs b/src/Files.App/Utils/Shell/ContextMenu.cs index 01354324a24e..788d5fe44841 100644 --- a/src/Files.App/Utils/Shell/ContextMenu.cs +++ b/src/Files.App/Utils/Shell/ContextMenu.cs @@ -174,7 +174,7 @@ public async Task 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[] { "C:\\" }, Shell32.CMF.CMF_NORMAL); } private void EnumMenuItems(HMENU hMenu, List menuItemsResult, bool loadSubenus = false) diff --git a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs index 0299f7570cba..7dec57c4be9a 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs @@ -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("C:", StringComparison.OrdinalIgnoreCase) && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { LaunchHelper.LaunchSettings("page=SettingsPageStorageSenseStorageOverview&target=SystemSettings_StorageSense_VolumeListLink"); diff --git a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs index 3ddfc8b8f7db..827f4c9d2758 100644 --- a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs +++ b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs @@ -14,9 +14,6 @@ public sealed class CreateShortcutDialogViewModel : ObservableObject // User's working directory public readonly string WorkingDirectory; - // Placeholder text of destination path textbox - public readonly string DestinationPlaceholder = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\Users\"; - // Tells whether destination path exists public bool DestinationPathExists { get; set; } diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index ab81ba6ece79..05b144b85d86 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -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, "C:\\", StringComparison.OrdinalIgnoreCase)); ViewModel.CleanupDriveCommand = new AsyncRelayCommand(() => StorageSenseHelper.OpenStorageSenseAsync(props.Drive.Path)); ViewModel.FormatDriveCommand = new RelayCommand(async () => { diff --git a/tests/Files.InteractionTests/SessionManager.cs b/tests/Files.InteractionTests/SessionManager.cs index 787615d6524e..ad57ec0b6805 100644 --- a/tests/Files.InteractionTests/SessionManager.cs +++ b/tests/Files.InteractionTests/SessionManager.cs @@ -70,13 +70,13 @@ public static void CreateSession(TestContext _) if (_session is null) { // WinAppDriver is probably not running, so lets start it! - if (File.Exists($@"{Environment.GetEnvironmentVariable("ProgramFiles(x86)")}\Windows Application Driver\WinAppDriver.exe")) + if (File.Exists(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe")) { - Process.Start($@"{Environment.GetEnvironmentVariable("ProgramFiles(x86)")}\Windows Application Driver\WinAppDriver.exe"); + Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); } - else if (File.Exists($@"{Environment.GetEnvironmentVariable("ProgramFiles")}\Windows Application Driver\WinAppDriver.exe")) + else if (File.Exists(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe")) { - Process.Start($@"{Environment.GetEnvironmentVariable("ProgramFiles")}\Windows Application Driver\WinAppDriver.exe"); + Process.Start(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe"); } else { From 4ce6c59a0316e4009321eb2691d1f119f26bda08 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:10:32 -0400 Subject: [PATCH 05/13] Update Package.appxmanifest --- src/Files.App (Package)/Package.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App (Package)/Package.appxmanifest b/src/Files.App (Package)/Package.appxmanifest index 925466d47122..3a70fa305a22 100644 --- a/src/Files.App (Package)/Package.appxmanifest +++ b/src/Files.App (Package)/Package.appxmanifest @@ -16,7 +16,7 @@ + Version="3.5.20.0" /> Files - Dev From 567f373f052161445534364322e70b576bdbcb65 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:54:26 -0400 Subject: [PATCH 06/13] Reapply "Code Quality: Update dependencies (#15810)" This reverts commit 583e7b2d6146016edc642dbe54172c2ffe010887. --- src/Files.App (Package)/Files.Package.wapproj | 2 +- .../Files.App.BackgroundTasks.csproj | 2 +- src/Files.App.Controls/Files.App.Controls.csproj | 4 ++-- src/Files.App.Server/Files.App.Server.csproj | 2 +- src/Files.App/Files.App.csproj | 8 ++++---- src/Files.Shared/Files.Shared.csproj | 2 +- tests/Files.App.UITests/Files.App.UITests.csproj | 2 +- .../Files.InteractionTests/Files.InteractionTests.csproj | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Files.App (Package)/Files.Package.wapproj b/src/Files.App (Package)/Files.Package.wapproj index ecd9c6ab3ffd..37c1cce34459 100644 --- a/src/Files.App (Package)/Files.Package.wapproj +++ b/src/Files.App (Package)/Files.Package.wapproj @@ -107,7 +107,7 @@ - + diff --git a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj index 297b1bc9976c..bc79f3d79537 100644 --- a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj +++ b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index f222efed7434..1be6e0d8325e 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/Files.App.Server/Files.App.Server.csproj b/src/Files.App.Server/Files.App.Server.csproj index 89c1fc9b757a..3a5bcc6e9271 100644 --- a/src/Files.App.Server/Files.App.Server.csproj +++ b/src/Files.App.Server/Files.App.Server.csproj @@ -39,7 +39,7 @@ - + diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index d73ab03500a2..3dd0139ad92a 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -71,15 +71,15 @@ - + - + - + @@ -91,7 +91,7 @@ - + diff --git a/src/Files.Shared/Files.Shared.csproj b/src/Files.Shared/Files.Shared.csproj index 30954645ae4e..d3611aa761f7 100644 --- a/src/Files.Shared/Files.Shared.csproj +++ b/src/Files.Shared/Files.Shared.csproj @@ -21,7 +21,7 @@ - + diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index e3aafa619a96..94198bb15af7 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -20,7 +20,7 @@ - + diff --git a/tests/Files.InteractionTests/Files.InteractionTests.csproj b/tests/Files.InteractionTests/Files.InteractionTests.csproj index f99d723fb0c3..58431406006a 100644 --- a/tests/Files.InteractionTests/Files.InteractionTests.csproj +++ b/tests/Files.InteractionTests/Files.InteractionTests.csproj @@ -21,8 +21,8 @@ - - + + From 4aefaa524d920b6f027f351a9e878d46ef14c451 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:54:40 -0400 Subject: [PATCH 07/13] Update Package.appxmanifest --- src/Files.App (Package)/Package.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App (Package)/Package.appxmanifest b/src/Files.App (Package)/Package.appxmanifest index 3a70fa305a22..c4182614d0c9 100644 --- a/src/Files.App (Package)/Package.appxmanifest +++ b/src/Files.App (Package)/Package.appxmanifest @@ -16,7 +16,7 @@ + Version="3.5.21.0" /> Files - Dev From 5de4b21f397e2c7d086358604664fe02123fe0f1 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:27:29 -0400 Subject: [PATCH 08/13] Revert "Reapply "Code Quality: Update dependencies (#15810)"" This reverts commit 567f373f052161445534364322e70b576bdbcb65. --- src/Files.App (Package)/Files.Package.wapproj | 2 +- .../Files.App.BackgroundTasks.csproj | 2 +- src/Files.App.Controls/Files.App.Controls.csproj | 4 ++-- src/Files.App.Server/Files.App.Server.csproj | 2 +- src/Files.App/Files.App.csproj | 8 ++++---- src/Files.Shared/Files.Shared.csproj | 2 +- tests/Files.App.UITests/Files.App.UITests.csproj | 2 +- .../Files.InteractionTests/Files.InteractionTests.csproj | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Files.App (Package)/Files.Package.wapproj b/src/Files.App (Package)/Files.Package.wapproj index 37c1cce34459..ecd9c6ab3ffd 100644 --- a/src/Files.App (Package)/Files.Package.wapproj +++ b/src/Files.App (Package)/Files.Package.wapproj @@ -107,7 +107,7 @@ - + diff --git a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj index bc79f3d79537..297b1bc9976c 100644 --- a/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj +++ b/src/Files.App.BackgroundTasks/Files.App.BackgroundTasks.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/Files.App.Controls/Files.App.Controls.csproj b/src/Files.App.Controls/Files.App.Controls.csproj index 1be6e0d8325e..f222efed7434 100644 --- a/src/Files.App.Controls/Files.App.Controls.csproj +++ b/src/Files.App.Controls/Files.App.Controls.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/Files.App.Server/Files.App.Server.csproj b/src/Files.App.Server/Files.App.Server.csproj index 3a5bcc6e9271..89c1fc9b757a 100644 --- a/src/Files.App.Server/Files.App.Server.csproj +++ b/src/Files.App.Server/Files.App.Server.csproj @@ -39,7 +39,7 @@ - + diff --git a/src/Files.App/Files.App.csproj b/src/Files.App/Files.App.csproj index 3dd0139ad92a..d73ab03500a2 100644 --- a/src/Files.App/Files.App.csproj +++ b/src/Files.App/Files.App.csproj @@ -71,15 +71,15 @@ - + - + - + @@ -91,7 +91,7 @@ - + diff --git a/src/Files.Shared/Files.Shared.csproj b/src/Files.Shared/Files.Shared.csproj index d3611aa761f7..30954645ae4e 100644 --- a/src/Files.Shared/Files.Shared.csproj +++ b/src/Files.Shared/Files.Shared.csproj @@ -21,7 +21,7 @@ - + diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index 94198bb15af7..e3aafa619a96 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -20,7 +20,7 @@ - + diff --git a/tests/Files.InteractionTests/Files.InteractionTests.csproj b/tests/Files.InteractionTests/Files.InteractionTests.csproj index 58431406006a..f99d723fb0c3 100644 --- a/tests/Files.InteractionTests/Files.InteractionTests.csproj +++ b/tests/Files.InteractionTests/Files.InteractionTests.csproj @@ -21,8 +21,8 @@ - - + + From d4696f5caf88e90c56f68bd3b944f8ca7d3f5026 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:27:55 -0400 Subject: [PATCH 09/13] Reapply "Code Quality: Use `%SYSTEMDRIVE%` environment variable instead of `C:` (#15805)" This reverts commit 647aa4bc70e90bd9512fb66d719130da02ee13f4. --- src/Files.App.Launcher/FilesLauncher.cpp | 2 +- src/Files.App.OpenDialog/FilesOpenDialog.cpp | 7 +++++-- src/Files.App.SaveDialog/FilesSaveDialog.cpp | 7 +++++-- src/Files.App/Data/Items/DriveItem.cs | 2 +- src/Files.App/Dialogs/CreateShortcutDialog.xaml | 2 +- src/Files.App/Services/Storage/StorageDevicesService.cs | 2 +- .../Utils/Cloud/Detector/LucidLinkCloudDetector.cs | 2 +- src/Files.App/Utils/Shell/ContextMenu.cs | 2 +- src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs | 2 +- .../ViewModels/Dialogs/CreateShortcutDialogViewModel.cs | 3 +++ src/Files.App/ViewModels/Properties/BasePropertiesPage.cs | 2 +- tests/Files.InteractionTests/SessionManager.cs | 8 ++++---- 12 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Files.App.Launcher/FilesLauncher.cpp b/src/Files.App.Launcher/FilesLauncher.cpp index dfe08e6e9170..4873f8ee563a 100644 --- a/src/Files.App.Launcher/FilesLauncher.cpp +++ b/src/Files.App.Launcher/FilesLauncher.cpp @@ -65,7 +65,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine LocalFree(szArglist); WCHAR szBuf[MAX_PATH]; - ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); std::wcout << szBuf << std::endl; if (_waccess(szBuf, 0) == -1) { diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.cpp b/src/Files.App.OpenDialog/FilesOpenDialog.cpp index 5b0659fb8b25..f1dec80b6568 100644 --- a/src/Files.App.OpenDialog/FilesOpenDialog.cpp +++ b/src/Files.App.OpenDialog/FilesOpenDialog.cpp @@ -21,7 +21,10 @@ using std::endl; CComPtr GetSystemDialog() { - HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false); + WCHAR comdlg32Path[MAX_PATH]; + ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); + + HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); CComPtr pClassFactory; @@ -159,7 +162,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.cpp b/src/Files.App.SaveDialog/FilesSaveDialog.cpp index b89c3e411105..b17d018e78f9 100644 --- a/src/Files.App.SaveDialog/FilesSaveDialog.cpp +++ b/src/Files.App.SaveDialog/FilesSaveDialog.cpp @@ -20,7 +20,10 @@ using std::endl; CComPtr GetSystemDialog() { - HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false); + WCHAR comdlg32Path[MAX_PATH]; + ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\comdlg32.dll", comdlg32Path, MAX_PATH - 1); + + HINSTANCE lib = CoLoadLibrary(comdlg32Path, false); BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject"); CComPtr pClassFactory; @@ -435,7 +438,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStrings(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index a7668d8ff88c..6f74e7db8ee6 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -240,7 +240,7 @@ public static async Task CreateFromPropertiesAsync(StorageFolder root IsLocationItem = true, ShowEjectDevice = item.IsRemovable, ShowShellItems = true, - ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, "C:\\", StringComparison.OrdinalIgnoreCase)), + ShowFormatDrive = !(item.Type == DriveType.Network || string.Equals(root.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase)), ShowProperties = true }; item.Path = string.IsNullOrEmpty(root.Path) ? $"\\\\?\\{root.Name}\\" : root.Path; diff --git a/src/Files.App/Dialogs/CreateShortcutDialog.xaml b/src/Files.App/Dialogs/CreateShortcutDialog.xaml index 6fb503d885e9..554f53e5a24b 100644 --- a/src/Files.App/Dialogs/CreateShortcutDialog.xaml +++ b/src/Files.App/Dialogs/CreateShortcutDialog.xaml @@ -50,7 +50,7 @@ Grid.Row="2" Grid.Column="0" HorizontalAlignment="Stretch" - PlaceholderText="C:\Users\" + PlaceholderText="{x:Bind ViewModel.DestinationPlaceholder, Mode=OneWay}" Text="{x:Bind ViewModel.DestinationItemPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> GetDrivesAsync() public async Task GetPrimaryDriveAsync() { - string cDrivePath = @"C:\"; + string cDrivePath = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\"; return new WindowsStorageFolder(await StorageFolder.GetFolderFromPathAsync(cDrivePath)); } diff --git a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs index 92dbed1f8d98..49a5f83a3224 100644 --- a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs @@ -28,7 +28,7 @@ protected override async IAsyncEnumerable GetProviders() string syncFolder = inner.GetProperty("filespaceName").GetString(); string[] orgNameFilespaceName = syncFolder.Split("."); - string path = Path.Combine(@"C:\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]); + string path = Path.Combine($@"{Environment.GetEnvironmentVariable("SystemDrive")}\Volumes", orgNameFilespaceName[1], orgNameFilespaceName[0]); string filespaceName = orgNameFilespaceName[0]; string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Lucid", "resources", "Logo.ico"); diff --git a/src/Files.App/Utils/Shell/ContextMenu.cs b/src/Files.App/Utils/Shell/ContextMenu.cs index 788d5fe44841..01354324a24e 100644 --- a/src/Files.App/Utils/Shell/ContextMenu.cs +++ b/src/Files.App/Utils/Shell/ContextMenu.cs @@ -174,7 +174,7 @@ public async Task InvokeItem(int itemID) public static async Task WarmUpQueryContextMenuAsync() { - using var cMenu = await GetContextMenuForFiles(new string[] { "C:\\" }, Shell32.CMF.CMF_NORMAL); + using var cMenu = await GetContextMenuForFiles(new string[] { $@"{Environment.GetEnvironmentVariable("SystemDrive")}\" }, Shell32.CMF.CMF_NORMAL); } private void EnumMenuItems(HMENU hMenu, List menuItemsResult, bool loadSubenus = false) diff --git a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs index 7dec57c4be9a..0299f7570cba 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs @@ -10,7 +10,7 @@ internal sealed class StorageSenseHelper { public static async Task OpenStorageSenseAsync(string path) { - if (!path.StartsWith("C:", StringComparison.OrdinalIgnoreCase) + if (!path.StartsWith(Environment.GetEnvironmentVariable("SystemDrive"), StringComparison.OrdinalIgnoreCase) && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { LaunchHelper.LaunchSettings("page=SettingsPageStorageSenseStorageOverview&target=SystemSettings_StorageSense_VolumeListLink"); diff --git a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs index 827f4c9d2758..3ddfc8b8f7db 100644 --- a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs +++ b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs @@ -14,6 +14,9 @@ public sealed class CreateShortcutDialogViewModel : ObservableObject // User's working directory public readonly string WorkingDirectory; + // Placeholder text of destination path textbox + public readonly string DestinationPlaceholder = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\Users\"; + // Tells whether destination path exists public bool DestinationPathExists { get; set; } diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index 05b144b85d86..ab81ba6ece79 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -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, "C:\\", StringComparison.OrdinalIgnoreCase)); + ViewModel.FormatVisibility = !(props.Drive.Type == DriveType.Network || string.Equals(props.Drive.Path, $@"{Environment.GetEnvironmentVariable("SystemDrive")}\", StringComparison.OrdinalIgnoreCase)); ViewModel.CleanupDriveCommand = new AsyncRelayCommand(() => StorageSenseHelper.OpenStorageSenseAsync(props.Drive.Path)); ViewModel.FormatDriveCommand = new RelayCommand(async () => { diff --git a/tests/Files.InteractionTests/SessionManager.cs b/tests/Files.InteractionTests/SessionManager.cs index ad57ec0b6805..787615d6524e 100644 --- a/tests/Files.InteractionTests/SessionManager.cs +++ b/tests/Files.InteractionTests/SessionManager.cs @@ -70,13 +70,13 @@ public static void CreateSession(TestContext _) if (_session is null) { // WinAppDriver is probably not running, so lets start it! - if (File.Exists(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe")) + if (File.Exists($@"{Environment.GetEnvironmentVariable("ProgramFiles(x86)")}\Windows Application Driver\WinAppDriver.exe")) { - Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); + Process.Start($@"{Environment.GetEnvironmentVariable("ProgramFiles(x86)")}\Windows Application Driver\WinAppDriver.exe"); } - else if (File.Exists(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe")) + else if (File.Exists($@"{Environment.GetEnvironmentVariable("ProgramFiles")}\Windows Application Driver\WinAppDriver.exe")) { - Process.Start(@"C:\Program Files\Windows Application Driver\WinAppDriver.exe"); + Process.Start($@"{Environment.GetEnvironmentVariable("ProgramFiles")}\Windows Application Driver\WinAppDriver.exe"); } else { From 45ec0dfb6c45994aa2b5b713ea3f00dd11bf2632 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:28:03 -0400 Subject: [PATCH 10/13] Reapply "Code Quality: Fallback to "C:\" when var doesn't work (#15842)" This reverts commit f588fa4e10886356e2871f184bc767017f09f140. --- src/Files.App/Constants.cs | 8 ++++++++ src/Files.App/Data/Items/DriveItem.cs | 2 +- src/Files.App/Services/Storage/StorageDevicesService.cs | 2 +- .../Utils/Cloud/Detector/LucidLinkCloudDetector.cs | 2 +- src/Files.App/Utils/Shell/ContextMenu.cs | 2 +- src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs | 2 +- .../ViewModels/Dialogs/CreateShortcutDialogViewModel.cs | 2 +- src/Files.App/ViewModels/Properties/BasePropertiesPage.cs | 2 +- 8 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Files.App/Constants.cs b/src/Files.App/Constants.cs index 46e4325eeea5..eb71b9366eb5 100644 --- a/src/Files.App/Constants.cs +++ b/src/Files.App/Constants.cs @@ -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 ShellPlaces = new() { diff --git a/src/Files.App/Data/Items/DriveItem.cs b/src/Files.App/Data/Items/DriveItem.cs index 6f74e7db8ee6..0168e683b839 100644 --- a/src/Files.App/Data/Items/DriveItem.cs +++ b/src/Files.App/Data/Items/DriveItem.cs @@ -240,7 +240,7 @@ public static async Task 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; diff --git a/src/Files.App/Services/Storage/StorageDevicesService.cs b/src/Files.App/Services/Storage/StorageDevicesService.cs index a8b355b143ec..e415b0a9fb09 100644 --- a/src/Files.App/Services/Storage/StorageDevicesService.cs +++ b/src/Files.App/Services/Storage/StorageDevicesService.cs @@ -55,7 +55,7 @@ public async IAsyncEnumerable GetDrivesAsync() public async Task GetPrimaryDriveAsync() { - string cDrivePath = $@"{Environment.GetEnvironmentVariable("SystemDrive")}\"; + string cDrivePath = $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\"; return new WindowsStorageFolder(await StorageFolder.GetFolderFromPathAsync(cDrivePath)); } diff --git a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs index 49a5f83a3224..74ccb39f5dcb 100644 --- a/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs +++ b/src/Files.App/Utils/Cloud/Detector/LucidLinkCloudDetector.cs @@ -28,7 +28,7 @@ protected override async IAsyncEnumerable 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"); diff --git a/src/Files.App/Utils/Shell/ContextMenu.cs b/src/Files.App/Utils/Shell/ContextMenu.cs index 01354324a24e..dbef74c3696c 100644 --- a/src/Files.App/Utils/Shell/ContextMenu.cs +++ b/src/Files.App/Utils/Shell/ContextMenu.cs @@ -174,7 +174,7 @@ public async Task 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 menuItemsResult, bool loadSubenus = false) diff --git a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs index 0299f7570cba..4679ee851af2 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageSenseHelper.cs @@ -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"); diff --git a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs index 3ddfc8b8f7db..f8012b42c568 100644 --- a/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs +++ b/src/Files.App/ViewModels/Dialogs/CreateShortcutDialogViewModel.cs @@ -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; } diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index ab81ba6ece79..5524d9e5bc24 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -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 () => { From 14df0bff8dc2690877835c015007ee1b9266e7f4 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:28:15 -0400 Subject: [PATCH 11/13] Update Package.appxmanifest --- src/Files.App (Package)/Package.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App (Package)/Package.appxmanifest b/src/Files.App (Package)/Package.appxmanifest index c4182614d0c9..f8ef4ef79077 100644 --- a/src/Files.App (Package)/Package.appxmanifest +++ b/src/Files.App (Package)/Package.appxmanifest @@ -16,7 +16,7 @@ + Version="3.5.22.0" /> Files - Dev From c0dc9c3420de43b12921ab81984e0e606e896ada Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:09:56 -0400 Subject: [PATCH 12/13] Reapply "Fix: Fixed FileNotFoundException in Recycle Bin watcher (#15808)" This reverts commit 7c7d14dc40d811cdbed46f40f4d000a3a157db44. --- .../Utils/RecycleBin/RecycleBinManager.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs index 1a0548d6e2a1..8b834a19747a 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinManager.cs @@ -51,18 +51,21 @@ private void StartRecycleBinWatcher() if (drive.DriveType == SystemIO.DriveType.Network || !SystemIO.Directory.Exists(recyclePath)) continue; - SystemIO.FileSystemWatcher watcher = new() + SafetyExtensions.IgnoreExceptions(() => { - Path = recyclePath, - Filter = "*.*", - NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName - }; - - watcher.Created += RecycleBinWatcher_Changed; - watcher.Deleted += RecycleBinWatcher_Changed; - watcher.EnableRaisingEvents = true; - - binWatchers.Add(watcher); + SystemIO.FileSystemWatcher watcher = new() + { + Path = recyclePath, + Filter = "*.*", + NotifyFilter = SystemIO.NotifyFilters.LastWrite | SystemIO.NotifyFilters.FileName | SystemIO.NotifyFilters.DirectoryName + }; + + watcher.Created += RecycleBinWatcher_Changed; + watcher.Deleted += RecycleBinWatcher_Changed; + watcher.EnableRaisingEvents = true; + + binWatchers.Add(watcher); + }); } } From 50c6e0cc7b6a11fb18e88721917b206374bf2cfb Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:10:05 -0400 Subject: [PATCH 13/13] Update Package.appxmanifest --- src/Files.App (Package)/Package.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App (Package)/Package.appxmanifest b/src/Files.App (Package)/Package.appxmanifest index f8ef4ef79077..ace503993fba 100644 --- a/src/Files.App (Package)/Package.appxmanifest +++ b/src/Files.App (Package)/Package.appxmanifest @@ -16,7 +16,7 @@ + Version="3.5.23.0" /> Files - Dev