C#调用系统的复制、移动、删除文件对话框

     #region 调用系统的文件复制移动删除
        [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        private static extern bool SHFileOperation([In, Out]  SHFILEOPSTRUCT str);
        private const int FO_MOVE = 0x1;
        private const int FO_COPY = 0x2;
        private const int FO_DELETE = 0x3;
        private const ushort FOF_NOCONFIRMATION = 0x10;
        private const ushort FOF_ALLOWUNDO = 0x40;
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        public class SHFILEOPSTRUCT
        {

            public IntPtr hwnd;

            /// <summary> 

            /// 设置操作方式,移动:FO_MOVE,复制:FO_COPY,删除:FO_DELETE 

            /// </summary> 

            public UInt32 wFunc;

            /// <summary> 

            /// 源文件路径 

            /// </summary> 

            public string pFrom;

            /// <summary> 

            /// 目标文件路径 

            /// </summary> 

            public string pTo;

            /// <summary> 

            /// 允许恢复 

            /// </summary> 

            public UInt16 fFlags;

            /// <summary> 

            /// 监测有无中止 

            /// </summary> 

            public Int32 fAnyOperationsAborted;

            public IntPtr hNameMappings;

            /// <summary> 

            /// 设置标题 

            /// </summary> 

            public string lpszProgressTitle;

        }
        #endregion
        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="SourceFileName">文件源</param>
        /// <param name="DestFileName">目标路径</param>
        /// <returns>是否成功复制</returns>
        private bool CopyFile(string SourceFileName, string DestFileName)
        {

            SHFILEOPSTRUCT pm = new SHFILEOPSTRUCT();

            pm.wFunc = FO_COPY;

            pm.pFrom = SourceFileName;

            pm.pTo = DestFileName;

            pm.fFlags = FOF_ALLOWUNDO;//允许恢复 

            pm.lpszProgressTitle = "文件复制";

            return !SHFileOperation(pm);
        }
原文地址:https://www.cnblogs.com/qq1223558/p/3120547.html