访问回收站

时间:2012-11-03 10:36:44

标签: vb.net

我想检查回收站中的文件,就像它是一个普通目录一样,特别是获取那里的文件列表以及每个文件到达回收站的日期。

1 个答案:

答案 0 :(得分:5)

此代码可以帮助您

'Access the recycle bin folder  
    Dim SH As New Shell32.Shell  
    Dim RecycleBin As Shell32.Folder = SH.NameSpace(Shell32.ShellSpecialFolderConstants.ssfBITBUCKET)  

    Dim SB As New StringBuilder  
    'Loop through the Recycle Bin and get each Items Name  
    For Each Item As Shell32.FolderItem In RecycleBin.Items  
        SB.AppendLine(Item.Name)  
    Next Item  

    'Display the list of filenames in a label  
    Label1.Text = SB.ToString