Changeset 1782


Ignore:
Timestamp:
2/9/2010 8:18:29 AM (4 years ago)
Author:
lowjoel
Message:

Fixed DirectoryNotFoundException? -- the Erase If Empty option for directories were not respected -- directories were always erased.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0/Eraser.Manager/DirectExecutor.cs

    r1754 r1782  
    870870                        fsManager.DeleteFolder(info); 
    871871                }; 
    872                 eraseEmptySubFolders(new DirectoryInfo(fldr.Path)); 
     872 
     873                DirectoryInfo directory = new DirectoryInfo(fldr.Path); 
     874                foreach (DirectoryInfo subDir in directory.GetDirectories()) 
     875                    eraseEmptySubFolders(subDir); 
    873876 
    874877                if (fldr.DeleteIfEmpty) 
    875878                { 
    876                     DirectoryInfo info = new DirectoryInfo(fldr.Path); 
    877                     progress.Event.CurrentItemName = info.FullName; 
     879                    progress.Event.CurrentItemName = directory.FullName; 
    878880                    task.OnProgressChanged(progress.Event); 
    879881 
    880882                    //See if this is the root of a volume. 
    881                     bool isVolumeRoot = info.Parent == null; 
     883                    bool isVolumeRoot = directory.Parent == null; 
    882884                    foreach (VolumeInfo volume in VolumeInfo.Volumes) 
    883885                        foreach (string mountPoint in volume.MountPoints) 
    884                             if (info.FullName == mountPoint) 
     886                            if (directory.FullName == mountPoint) 
    885887                                isVolumeRoot = true; 
    886888 
    887889                    //If the folder is a mount point, then don't delete it. If it isn't, 
    888890                    //search for files under the folder to see if it is empty. 
    889                     if (!isVolumeRoot && info.Exists && info.GetFiles("*", SearchOption.AllDirectories).Length == 0) 
    890                         fsManager.DeleteFolder(info); 
     891                    if (!isVolumeRoot && directory.Exists && 
     892                        directory.GetFiles("*", SearchOption.AllDirectories).Length == 0) 
     893                    { 
     894                        fsManager.DeleteFolder(directory); 
     895                    } 
    891896                } 
    892897            } 
Note: See TracChangeset for help on using the changeset viewer.