Exemple #1
0
        /// <summary>
        ///		<see cref="IFileProvider.Copy"/>
        /// </summary>
        public void Copy(string sourcePath, string destinationPath, bool overwrite)
        {
            var longPathSource      = new LongPath(sourcePath);
            var longPathDestination = new LongPath(destinationPath);

            bool result;

            if (KtmTransaction.IsInTransaction)
            {
                bool cancel = false;
                result = WindowsNative.CopyFileTransacted(
                    longPathSource.PathString
                    , longPathDestination.PathString
                    , IntPtr.Zero
                    , IntPtr.Zero
                    , ref cancel
                    , WindowsNative.CopyFileFlags.COPY_FILE_FAIL_IF_EXISTS
                    , KtmTransaction.Current.Hanlde);
            }
            else
            {
                result = WindowsNative.CopyFile(longPathSource.PathString, longPathDestination.PathString, !overwrite);
            }
            if (!result)
            {
                WindowsNative.HandleWindowsError();
            }
        }