Send a File to the Recycle Bin

后端 未结 8 1178
北海茫月
北海茫月 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:31

    There is built-in library for this .

    First add reference Microsoft.VisualBasic Then add this code :

    FileSystem.DeleteFile(path_of_the_file,
                            Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
                            Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin,
                            Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException);
    

    I have found this here .

提交回复
热议问题