Send a File to the Recycle Bin

后端 未结 8 1131
北海茫月
北海茫月 2020-11-27 10:59

Currently I\'m using the following function

file.Delete();

But how can I use this function to send a file to the recycle bin instead of jus

8条回答
  •  温柔的废话
    2020-11-27 11:29

    From MSDN:

    Add a reference to Microsoft.VisualBasic assembly. The needed class is found in this library.

    Add this using statement to the top of the file using Microsoft.VisualBasic.FileIO;

    Use FileSystem.DeleteFile to delete a file, it has the option to specify recycle bin or not.

    Use FileSystem.DeleteDirectory to delete a directory with the option to specify to send it to the recycle bin or not.

提交回复
热议问题