public static void DeleteWithUndo(string filePath) { string str = Microsoft.Expression.Framework.Documents.PathHelper.TrimTrailingDirectorySeparators(filePath); bool flag = File.Exists(str); Microsoft.Expression.Project.NativeMethods.SHFILEOPSTRUCT32 mainWindowHandle = new Microsoft.Expression.Project.NativeMethods.SHFILEOPSTRUCT32() { fFlags = 13396, hNameMappings = IntPtr.Zero }; try { mainWindowHandle.hwnd = Process.GetCurrentProcess().MainWindowHandle; } catch (Exception exception1) { Exception exception = exception1; if (!(exception is SecurityException) && !(exception is InvalidOperationException) && !(exception is NotSupportedException)) { throw; } mainWindowHandle.hwnd = IntPtr.Zero; } mainWindowHandle.lpszProgressTitle = string.Empty; mainWindowHandle.pFrom = string.Concat(str, "\0\0"); mainWindowHandle.pTo = null; mainWindowHandle.wFunc = 3; mainWindowHandle.fAnyOperationsAborted = false; if (IntPtr.Size == 4) { Microsoft.Expression.Project.NativeMethods.SHFileOperation32(ref mainWindowHandle); } else if (IntPtr.Size == 8) { Microsoft.Expression.Project.NativeMethods.SHFILEOPSTRUCT64 sHFILEOPSTRUCT64 = new Microsoft.Expression.Project.NativeMethods.SHFILEOPSTRUCT64() { fFlags = mainWindowHandle.fFlags, hNameMappings = mainWindowHandle.hNameMappings, hwnd = mainWindowHandle.hwnd, lpszProgressTitle = mainWindowHandle.lpszProgressTitle, pFrom = mainWindowHandle.pFrom, pTo = mainWindowHandle.pTo, wFunc = mainWindowHandle.wFunc, fAnyOperationsAborted = mainWindowHandle.fAnyOperationsAborted }; Microsoft.Expression.Project.NativeMethods.SHFileOperation64(ref sHFILEOPSTRUCT64); } if (flag) { Microsoft.Expression.Project.NativeMethods.SHChangeNotify(4, 5, str, IntPtr.Zero); return; } Microsoft.Expression.Project.NativeMethods.SHChangeNotify(16, 5, str, IntPtr.Zero); }
internal static extern int SHFileOperation32(ref Microsoft.Expression.Project.NativeMethods.SHFILEOPSTRUCT32 lpFileOp);