Put to recycle bin

In this chapter you will learn:

  1. How to send a file to the recycle bin

Delete to send a file to the recycle bin

using System.IO;//from  ja v a 2 s .  c  o  m
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text.RegularExpressions;

public class Utils
{

    public static void SendFileToRecycleBin(string sFile)
    {
        Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(
            sFile,
            Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
            Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
    }
}

Next chapter...

What you will learn in the next chapter:

  1. How to check if a file exists
Home » C# Tutorial » File, Path
File creation
Deleting Files
Put to recycle bin
File Exists
File moving
File size
File attribute
Set file attribute
File time change
File time
Random file name
Temporary file
Path
Directory creation
Delete directory
Path existance
Change the path
Current Path
Directory listing
Recursive Path Listing
Combine path
Calculate Directory Size
Invalid path characters
System path
Directory copy
Drive
Drive information
File access rule
File System watcher