c#如何获取回收站文件信息 如题,自己看有些说在“c:\\Recycled”下查找文件,但这个貌似行不通,就算获取了回收站路径,里面文件能像普通文件处理么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.csharpwin.com/csharpspace/9057r3801.shtml string[] MyFiles=Directory.GetFiles(driver+"\\Recycled"); http://www.csharpwin.com/csharpspace/4755r8292.shtml 不好意思,string[] MyFiles=Directory.GetFiles(driver+"\\Recycled"); driver是啥啊? 判断C盘根目录下面的"Recycled"目录是否为空。这个之前看过,但自己的Recycled文件夹是隐藏的,而且是空的,自己回收站貌似在C:\RECYCLER\S-1-5-21-1659004503-1788223648-1177238915-1003但用FileInfo不能正常获取下面的文件啊自己看用static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate)获取特殊文件路径看上面写的const int CSIDL_BITBUCKET =0x000a; // <desktop>\Recycle Bin那自己觉得10该是回收站对应的值,可用了之后,返回路径是空的,自己试了其他值貌似都正常啊 这个有意思!我觉得 WinAPI 烦,搞了个文件夹搜索的方法,你试试原理是搜索各个驱动器下包含 recycle 字符的文件夹判断文件夹属性是否包含隐藏和系统Type type = typeof(System.IO.FileAttributes);Console.WriteLine("values\tattributes");Console.WriteLine("-----------------------------");foreach (int value in Enum.GetValues(type)){ Console.WriteLine("{0}\t{1}", value, Enum.GetName(type, value));}Console.WriteLine("-----------------------------");foreach (var drive in System.IO.DriveInfo.GetDrives()){ if (drive.DriveType == System.IO.DriveType.Fixed) { System.IO.DirectoryInfo[] folders = drive.RootDirectory.GetDirectories("*recycle*"); foreach (var folder in folders) { Console.Write("({0})\t", (folder.Attributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory && (folder.Attributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden && (folder.Attributes & System.IO.FileAttributes.System) == System.IO.FileAttributes.System); Console.WriteLine(folder.FullName); Console.WriteLine("\tsttribs: {0}", folder.Attributes); } }} Datagridview显示Excel一列中不同类型数据时丢失数据 c#很难的一个算法,求解!!!!!!!!!!!!! 请问Console.Read()读的到底是哪个字符的ASCII码? 如何禁止键盘输入? ccccc datatable 如何 把 重复的数据相加 关于简单工厂模式(简单计算器例子)的讨论 请问怎样让ComBoBox弹出下拉列表?急!!!!!!!!!!! 在中文系统开发的程序界面拿到英文系统处变样?各位怎解决? 哪位高手推荐一本c#书籍 把dataGridView 中的数据 导出到excel 如何获取网页中这一连接字符串
这个之前看过,但自己的Recycled文件夹是隐藏的,而且是空的,
自己回收站貌似在C:\RECYCLER\S-1-5-21-1659004503-1788223648-1177238915-1003
但用FileInfo不能正常获取下面的文件啊
自己看用static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner,[Out] StringBuilder lpszPath, int nFolder, bool fCreate)获取特殊文件路径
看上面写的const int CSIDL_BITBUCKET =0x000a; // <desktop>\Recycle Bin
那自己觉得10该是回收站对应的值,可用了之后,返回路径是空的,自己试了其他值貌似都正常啊
我觉得 WinAPI 烦,搞了个文件夹搜索的方法,你试试原理是搜索各个驱动器下包含 recycle 字符的文件夹
判断文件夹属性是否包含隐藏和系统
Type type = typeof(System.IO.FileAttributes);Console.WriteLine("values\tattributes");
Console.WriteLine("-----------------------------");foreach (int value in Enum.GetValues(type))
{
Console.WriteLine("{0}\t{1}",
value, Enum.GetName(type, value));
}Console.WriteLine("-----------------------------");foreach (var drive in System.IO.DriveInfo.GetDrives())
{
if (drive.DriveType == System.IO.DriveType.Fixed)
{
System.IO.DirectoryInfo[] folders =
drive.RootDirectory.GetDirectories("*recycle*"); foreach (var folder in folders)
{
Console.Write("({0})\t",
(folder.Attributes & System.IO.FileAttributes.Directory)
== System.IO.FileAttributes.Directory &&
(folder.Attributes & System.IO.FileAttributes.Hidden)
== System.IO.FileAttributes.Hidden &&
(folder.Attributes & System.IO.FileAttributes.System)
== System.IO.FileAttributes.System); Console.WriteLine(folder.FullName);
Console.WriteLine("\tsttribs: {0}", folder.Attributes);
}
}
}