Last active
June 19, 2017 19:00
-
-
Save lockworld/1501cf759f2d91c0260b95f587962e76 to your computer and use it in GitHub Desktop.
Working with files in a C# application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Shell32; | |
using System; | |
namespace RecycleBin | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Type t = Type.GetTypeFromProgID("Shell.Application"); | |
dynamic shell = Activator.CreateInstance(t); | |
Folder RecycleBin = shell.NameSpace(ShellSpecialFolderConstants.ssfBITBUCKET); //ssfBITBUCKET is the user's recycle bin | |
RecycleBin.MoveHere(@"C:\Users\dlockwood\Documents\Temporary Files\DeleteMe.txt ",new int[] { 4, 64,512,9182 }); | |
/* | |
4: Do not display a progress dialog box | |
64: Preserve undo information, if possible | |
512: Do not confirm the creation of a new directory if the operation requires one to be created | |
9182: Do not move connected files as a group. Only move the specified files | |
*/ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move file to Recyle Bin: | |
http://nd.fyi/csRecycleBin | |
ShellSpecialFolderConstants: | |
https://msdn.microsoft.com/en-us/library/windows/desktop/bb774096(v=vs.85).aspx | |
Folder.MoveHere Options: | |
https://msdn.microsoft.com/en-us/library/windows/desktop/bb787874(v=vs.85).aspx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment