Changeset 2529


Ignore:
Timestamp:
03/15/12 01:29:57 (2 years ago)
Author:
lowjoel
Message:

Backport r2527 and r2522 from trunk: Improve recycle bin support: on drives not using NTFS, Windows stores recycle bin files directly within the $Recycle.Bin folder. On those drives, we would have to erase the global recycle bin for that drive.

Location:
branches/eraser6/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0

  • branches/eraser6/6.0/Eraser.Manager/Task.cs

    r2264 r2529  
    735735            string[] rootDirectory = new string[] { 
    736736                    "$RECYCLE.BIN", 
    737                     "RECYCLER" 
     737                    "RECYCLER", 
     738                    "RECYCLED" 
    738739                }; 
     740            string userSid = System.Security.Principal.WindowsIdentity.GetCurrent(). 
     741                User.ToString(); 
    739742 
    740743            foreach (DriveInfo drive in DriveInfo.GetDrives()) 
     
    742745                foreach (string rootDir in rootDirectory) 
    743746                { 
    744                     DirectoryInfo dir = new DirectoryInfo( 
    745                         System.IO.Path.Combine( 
    746                             System.IO.Path.Combine(drive.Name, rootDir), 
    747                             System.Security.Principal.WindowsIdentity.GetCurrent(). 
    748                                 User.ToString())); 
    749                     if (!dir.Exists) 
     747                    //First get the global recycle bin for the current drive 
     748                    string recycleBinPath = System.IO.Path.Combine( 
     749                        drive.Name, rootDir); 
     750                    if (!Directory.Exists(recycleBinPath)) 
    750751                        continue; 
    751752 
    752                     GetRecyclerFiles(dir, result, ref totalSize); 
     753                    //Try to see if we can get the user's own recycle bin 
     754                    if (Directory.Exists(System.IO.Path.Combine(recycleBinPath, userSid))) 
     755                        recycleBinPath = System.IO.Path.Combine(recycleBinPath, userSid); 
     756                    GetRecyclerFiles(new DirectoryInfo(recycleBinPath), result, ref totalSize); 
    753757                } 
    754758            } 
Note: See TracChangeset for help on using the changeset viewer.