From a32cd30bc685d4c1b4074d43c7a518f394065f72 Mon Sep 17 00:00:00 2001 From: Siox0911 Date: Thu, 31 Jul 2025 15:54:30 +0200 Subject: [PATCH 1/2] Update NativeMethods to support long path > 259 chars. --- .../Workers/FileTransferManager.cs | 4 ++-- VaraniumSharp.FileTransferManager/Workers/NativeMethods.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VaraniumSharp.FileTransferManager/Workers/FileTransferManager.cs b/VaraniumSharp.FileTransferManager/Workers/FileTransferManager.cs index edd7d1c..76ff99e 100644 --- a/VaraniumSharp.FileTransferManager/Workers/FileTransferManager.cs +++ b/VaraniumSharp.FileTransferManager/Workers/FileTransferManager.cs @@ -142,7 +142,7 @@ public static TransferResult MoveWithProgress(string source, string destination, return TransferResult.Cancelled; } - if (!NativeMethods.MoveFileWithProgress(source, destination, lpProgressRoutine, IntPtr.Zero, NativeMethods.MoveFileFlags.MOVE_FILE_REPLACE_EXISTING | NativeMethods.MoveFileFlags.MOVE_FILE_COPY_ALLOWED | NativeMethods.MoveFileFlags.MOVE_FILE_WRITE_THROUGH)) + if (!NativeMethods.MoveFileWithProgressW(source, destination, lpProgressRoutine, IntPtr.Zero, NativeMethods.MoveFileFlags.MOVE_FILE_REPLACE_EXISTING | NativeMethods.MoveFileFlags.MOVE_FILE_COPY_ALLOWED | NativeMethods.MoveFileFlags.MOVE_FILE_WRITE_THROUGH)) { if (cancellationToken.IsCancellationRequested) { @@ -301,7 +301,7 @@ private static TransferResult CopyFileWithProgress(string sourceFile, string new // TODO - Why is this done? var ctr = cancellationToken.Register(() => pbCancel = 1); - var result = NativeMethods.CopyFileEx(sourceFile, newFile, lpProgressRoutine, IntPtr.Zero, ref pbCancel, NativeMethods.CopyFileFlags.COPY_FILE_FAIL_IF_EXISTS); + var result = NativeMethods.CopyFileExW(sourceFile, newFile, lpProgressRoutine, IntPtr.Zero, ref pbCancel, NativeMethods.CopyFileFlags.COPY_FILE_FAIL_IF_EXISTS); if (cancellationToken.IsCancellationRequested) { return TransferResult.Cancelled; diff --git a/VaraniumSharp.FileTransferManager/Workers/NativeMethods.cs b/VaraniumSharp.FileTransferManager/Workers/NativeMethods.cs index 0b708c4..e3d4083 100644 --- a/VaraniumSharp.FileTransferManager/Workers/NativeMethods.cs +++ b/VaraniumSharp.FileTransferManager/Workers/NativeMethods.cs @@ -11,10 +11,10 @@ internal static class NativeMethods [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CopyFileEx(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref int pbCancel, CopyFileFlags dwCopyFlags); + internal static extern bool CopyFileExW(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, ref int pbCancel, CopyFileFlags dwCopyFlags); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - internal static extern bool MoveFileWithProgress(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwCopyFlags); + internal static extern bool MoveFileWithProgressW(string lpExistingFileName, string lpNewFileName, CopyProgressRoutine lpProgressRoutine, IntPtr lpData, MoveFileFlags dwCopyFlags); #endregion From 3bebcafd1c2022835b34340da1d8500842f88463 Mon Sep 17 00:00:00 2001 From: Siox0911 Date: Sun, 14 Sep 2025 14:37:23 +0200 Subject: [PATCH 2/2] Upgrade Nuget Packages --- .../VaraniumSharp.FileTransferManager.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VaraniumSharp.FileTransferManager/VaraniumSharp.FileTransferManager.csproj b/VaraniumSharp.FileTransferManager/VaraniumSharp.FileTransferManager.csproj index 05d338e..f456fba 100644 --- a/VaraniumSharp.FileTransferManager/VaraniumSharp.FileTransferManager.csproj +++ b/VaraniumSharp.FileTransferManager/VaraniumSharp.FileTransferManager.csproj @@ -27,12 +27,12 @@ - 6.8.0 + 6.14.0 runtime; build; native; contentfiles; analyzers; buildtransitive all - + \ No newline at end of file