如题,自己看有些说在“c:\\Recycled”下查找文件,但这个貌似行不通,就算获取了回收站路径,里面文件能像普通文件处理么?

解决方案 »

  1.   

    http://www.csharpwin.com/csharpspace/9057r3801.shtml
      

  2.   

    string[] MyFiles=Directory.GetFiles(driver+"\\Recycled");
      

  3.   

    http://www.csharpwin.com/csharpspace/4755r8292.shtml
      

  4.   

    不好意思,string[] MyFiles=Directory.GetFiles(driver+"\\Recycled"); driver是啥啊?
      

  5.   

    判断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该是回收站对应的值,可用了之后,返回路径是空的,自己试了其他值貌似都正常啊
      

  6.   

    这个有意思!
    我觉得 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);
            }
        }
    }