internal static int CopyFile(String src, String dst, bool failIfExists) { uint copyFlags = failIfExists ? (uint)Interop.Kernel32.FileOperations.COPY_FILE_FAIL_IF_EXISTS : 0; Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS parameters = new Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS() { dwSize = (uint)Marshal.SizeOf<Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS>(), dwCopyFlags = copyFlags }; int hr = Interop.Kernel32.CopyFile2(src, dst, ref parameters); return Win32Marshal.TryMakeWin32ErrorCodeFromHR(hr); }
internal static int CopyFile(string src, string dst, bool failIfExists) { uint copyFlags = failIfExists ? (uint)Interop.Kernel32.FileOperations.COPY_FILE_FAIL_IF_EXISTS : 0; Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS parameters = new Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS() { dwSize = (uint)Marshal.SizeOf <Interop.Kernel32.COPYFILE2_EXTENDED_PARAMETERS>(), dwCopyFlags = copyFlags }; int hr = Interop.Kernel32.CopyFile2(src, dst, ref parameters); return(Win32Marshal.TryMakeWin32ErrorCodeFromHR(hr)); }