예제 #1
0
        internal static int CopyFile(String src, String dst, bool failIfExists)
        {
            uint copyFlags = failIfExists ? Interop.COPY_FILE_FAIL_IF_EXISTS : 0;
            Interop.COPYFILE2_EXTENDED_PARAMETERS parameters = new Interop.COPYFILE2_EXTENDED_PARAMETERS()
            {
                dwSize = (uint)Marshal.SizeOf<Interop.COPYFILE2_EXTENDED_PARAMETERS>(),
                dwCopyFlags = copyFlags
            };

            int hr = CopyFile2(src, dst, ref parameters);

            return Win32Marshal.TryMakeWin32ErrorCodeFromHR(hr);
        }
예제 #2
0
        internal static int CopyFile(String src, String dst, bool failIfExists)
        {
            uint copyFlags = failIfExists ? Interop.COPY_FILE_FAIL_IF_EXISTS : 0;

            Interop.COPYFILE2_EXTENDED_PARAMETERS parameters = new Interop.COPYFILE2_EXTENDED_PARAMETERS()
            {
                dwSize      = (uint)Marshal.SizeOf <Interop.COPYFILE2_EXTENDED_PARAMETERS>(),
                dwCopyFlags = copyFlags
            };

            int hr = CopyFile2(src, dst, ref parameters);

            return(Win32Marshal.TryMakeWin32ErrorCodeFromHR(hr));
        }