How can I tell that a directory is the recycle bin in C#?

后端 未结 3 1523
花落未央
花落未央 2020-12-16 16:08

Given a folder, how can I tell that it is a recycle bin? I\'ve found an answer for C++ but not for C#.

My first idea was to check for FileAttributes.System (which wo

3条回答
  •  醉梦人生
    2020-12-16 17:03

    Microsoft's Windows API Code Pack contains this functionality.

    To get the folder of the Recycle Bin, use

    Microsoft.WindowsAPICodePack.Shell.KnownFolderHelper.FromPath("::{645FF040-5081-101B-9F08-00AA002F954E}");
    

    I've no idea what that string means, but it was included in the docs as the reference to the Recycle Bin.

    Hope this helps :)

提交回复
热议问题