示例#1
0
        public bool DoOperation()
        {
            var FileOpStruct = new Native.SHFILEOPSTRUCT();

            FileOpStruct.hwnd  = OwnerWindow;
            FileOpStruct.wFunc = (uint)Operation;

            var multiSource = StringArrayToMultiString(SourceFiles);
            var multiDest   = StringArrayToMultiString(DestFiles);

            FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource);
            FileOpStruct.pTo   = Marshal.StringToHGlobalUni(multiDest);

            FileOpStruct.fFlags                = (ushort)OperationFlags;
            FileOpStruct.lpszProgressTitle     = ProgressTitle;
            FileOpStruct.fAnyOperationsAborted = 0;
            FileOpStruct.hNameMappings         = IntPtr.Zero;

            int RetVal;

            RetVal = Native.Methods.SHFileOperation(ref FileOpStruct);

            Native.Methods.SHChangeNotify(
                (uint)ShellChangeNotificationEvents.SHCNE_ALLEVENTS,
                (uint)ShellChangeNotificationFlags.SHCNF_DWORD,
                IntPtr.Zero,
                IntPtr.Zero);

            if (RetVal != 0)
            {
                return(false);
            }

            if (FileOpStruct.fAnyOperationsAborted != 0)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
 public static extern Int32 SHFileOperation(
     ref SHFILEOPSTRUCT lpFileOp);
示例#3
0
 public static extern Int32 SHFileOperation(
     ref SHFILEOPSTRUCT lpFileOp);
        public bool DoOperation()
        {
            Native.SHFILEOPSTRUCT FileOpStruct = new Native.SHFILEOPSTRUCT();

            FileOpStruct.hwnd = OwnerWindow;
            FileOpStruct.wFunc = (uint)Operation;

            String multiSource = StringArrayToMultiString(SourceFiles);
            String multiDest = StringArrayToMultiString(DestFiles);
            FileOpStruct.pFrom = Marshal.StringToHGlobalUni(multiSource);
            FileOpStruct.pTo = Marshal.StringToHGlobalUni(multiDest);

            FileOpStruct.fFlags = (ushort)OperationFlags;
            FileOpStruct.lpszProgressTitle = ProgressTitle;
            FileOpStruct.fAnyOperationsAborted = 0;
            FileOpStruct.hNameMappings = IntPtr.Zero;

            int RetVal;
            RetVal = Native.Methods.SHFileOperation(ref FileOpStruct);

            Native.Methods.SHChangeNotify(
                (uint)ShellChangeNotificationEvents.SHCNE_ALLEVENTS,
                (uint)ShellChangeNotificationFlags.SHCNF_DWORD,
                IntPtr.Zero,
                IntPtr.Zero);

            if (RetVal!=0)
                return false;

            if (FileOpStruct.fAnyOperationsAborted != 0)
                return false;

            return true;
        }