如何使用c#从回收站中删除文件 [英] How to delete files from recycle bin using c#

查看:116
本文介绍了如何使用c#从回收站中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我想使用我的应用程序从回收站中删除所有文件和文件夹。


I want to delete all files and folders from recycle bin using my app.

shl = new Shell();
Folder Recycler = shl.NameSpace(10);

       for (int i = 0; i < Recycler.Items().Count; i++)
       {

           FolderItem FI = Recycler.Items().Item(i);
           string FileName = Recycler.GetDetailsOf(FI, 0);
           label1.Text = FileName.ToString();
           if (Path.GetExtension(FileName) == "")
               FileName += Path.GetExtension(FI.Path);

           //Necessary for systems with hidden file extensions.

           string FilePath = Recycler.GetDetailsOf(FI, 1);

           lbl_tmp.Text = FilePath.ToString();





使用上面的代码我成功检索了回收站中存在的文件名,但我无法删除这些文件。任何人都可以帮我解决这个问题。



提前谢谢



using above code I got success in retrieving the name of file which are present in recycle bin , but I am unable to delete these file. Can anyone help me in this matter.

Thanks in advance

推荐答案

参考这个链接可能会解决你的问题



http://www.aspfree.com/c/a/ASP.NET-Code/Using-C-empty-recycle-bin-by-Mahesh/ [<一个href =http://www.aspfree.com/c/a/ASP.NET-Code/Using-C-empty-recycle-bin-by-Mahesh/target =_ blanktitle =New Window> ^ ]
Refer this link it may solve your problem

http://www.aspfree.com/c/a/ASP.NET-Code/Using-C-empty-recycle-bin-by-Mahesh/[^]


参考



how-to-empty-recycle-bin-using-c.html [ ^ ]







码样本换空再循环彬在-C / [ ^ ]


我在Google上搜索了从回收站中删除c# [ ^ ]这是第一个链接 - 正在删除单个项目FROM回收站 [ ^ ]。我浏览了一下这些帖子,看来你的回答似乎是这样的。



请在询问之前进行搜索。
I searched Google for delete from recycle bin c#[^] and this was the first link - Deleting a single item FROM recycle bin[^]. I glanced through the posts and it seems you have your answer here.

Please do search before you ask.


这篇关于如何使用c#从回收站中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆