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); }
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; }