diff --git a/src/Files.App/Helpers/Interop/NativeFileOperationsHelper.cs b/src/Files.App/Helpers/Interop/NativeFileOperationsHelper.cs index f120ebd469f4..ea093e24f98c 100644 --- a/src/Files.App/Helpers/Interop/NativeFileOperationsHelper.cs +++ b/src/Files.App/Helpers/Interop/NativeFileOperationsHelper.cs @@ -123,39 +123,6 @@ private static extern bool DeviceIoControl( out uint lpBytesReturned, IntPtr lpOverlapped); - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, - CallingConvention = CallingConvention.StdCall, - SetLastError = true)] - public static extern IntPtr CreateFile2FromApp( - string lpFileName, - uint dwDesiredAccess, - uint dwShareMode, - uint dwCreationDisposition, - IntPtr pCreateExParams - ); - - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, - CallingConvention = CallingConvention.StdCall, - SetLastError = true)] - public static extern bool CreateDirectoryFromApp( - string lpPathName, - IntPtr SecurityAttributes - ); - - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, - CallingConvention = CallingConvention.StdCall, - SetLastError = true)] - public static extern bool DeleteFileFromApp( - string lpFileName - ); - - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, - CallingConvention = CallingConvention.StdCall, - SetLastError = true)] - public static extern bool RemoveDirectoryFromApp( - string lpPathName - ); - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", SetLastError = true, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetFileAttributesExFromApp( diff --git a/src/Files.App/NativeMethods.txt b/src/Files.App/NativeMethods.txt index 9e0590a75225..ab25af5291fe 100644 --- a/src/Files.App/NativeMethods.txt +++ b/src/Files.App/NativeMethods.txt @@ -43,4 +43,5 @@ CopyFileFromApp MoveFileFromApp DeleteFileFromApp RemoveDirectoryFromApp -GetKeyState \ No newline at end of file +GetKeyState +CreateDirectoryFromApp \ No newline at end of file diff --git a/src/Files.App/Utils/Serialization/Implementation/DefaultSettingsSerializer.cs b/src/Files.App/Utils/Serialization/Implementation/DefaultSettingsSerializer.cs index 049c99a0ca95..c2309bee5608 100644 --- a/src/Files.App/Utils/Serialization/Implementation/DefaultSettingsSerializer.cs +++ b/src/Files.App/Utils/Serialization/Implementation/DefaultSettingsSerializer.cs @@ -1,9 +1,8 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.Shared.Extensions; -using System; using System.IO; +using Windows.Win32; using static Files.App.Helpers.NativeFileOperationsHelper; namespace Files.App.Utils.Serialization.Implementation @@ -14,7 +13,7 @@ internal sealed class DefaultSettingsSerializer : ISettingsSerializer public bool CreateFile(string path) { - CreateDirectoryFromApp(Path.GetDirectoryName(path), IntPtr.Zero); + PInvoke.CreateDirectoryFromApp(Path.GetDirectoryName(path), null); var hFile = CreateFileFromApp(path, GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_ALWAYS, (uint)File_Attributes.BackupSemantics, IntPtr.Zero); if (hFile.IsHandleInvalid())