Example #1
0
        /*
         * CopyFile - Copy a file to/from a local or remote file system.
         */
        public static WinError CopyFile(
            string lpExistingFileName,
            string lpNewFileName,
            bool bFailIfExists
            )
        {
            bool     copied = false;
            WinError error  = 0;

            if (useWindowsDlls)
            {
                copied = InteropWindows.CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists);

                if (!copied)
                {
                    error = (WinError)Marshal.GetLastWin32Error();
                }
            }
            else
            {
                copied = InteropLikewise.CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists);

                if (!copied)
                {
                    error = (WinError)InteropLikewise.GetLastError();
                }
            }

            return(error);
        }