Skip to content

Instantly share code, notes, and snippets.

@timdetering
Created November 1, 2019 03:26
Show Gist options
  • Save timdetering/55f8a7b2b23ef47d5c3ddcae0c8cd635 to your computer and use it in GitHub Desktop.
Save timdetering/55f8a7b2b23ef47d5c3ddcae0c8cd635 to your computer and use it in GitHub Desktop.
DeleteToRecycleBin
public class DeleteToRecycleBin
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
public struct SHFILEOPSTRUCT
{
public IntPtr hwnd;
[MarshalAs(UnmanagedType.U4)]
public int wFunc;
public string pFrom;
public string pTo;
public short fFlags;
[MarshalAs(UnmanagedType.Bool)]
public bool fAnyOperationsAborted;
public IntPtr hNameMappings;
public string lpszProgressTitle;
}
[DllImport("shell32.dll", CharSet = CharSet.Auto)]
public static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp);
public const int FO_DELETE = 3;
public const int FOF_ALLOWUNDO = 0x40;
public const int FOF_NOCONFIRMATION = 0x10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment