Ignore:
Timestamp:
3/1/2010 9:36:02 AM (2 years ago)
Author:
lowjoel
Message:

Define a discrete SharingViolationException? which is thrown when a file is currently in use. This makes handling such errors easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Manager/Task.cs

    r1853 r1872  
    461461            { 
    462462            } 
    463             catch (IOException) 
    464             { 
    465                 if (System.Runtime.InteropServices.Marshal.GetLastWin32Error() == 
    466                     Win32ErrorCode.SharingViolation) 
    467                 { 
    468                     //The system cannot open the file, try to force the file handle to close. 
    469                     if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) 
    470                         throw; 
    471  
    472                     foreach (OpenHandle handle in OpenHandle.Items) 
    473                         if (handle.Path == file && handle.Close()) 
    474                         { 
    475                             GetPathADSes(list, out totalSize, file); 
    476                             return; 
    477                         } 
    478                 } 
    479                 else 
     463            catch (SharingViolationException) 
     464            { 
     465                //The system cannot open the file, try to force the file handle to close. 
     466                if (!ManagerLibrary.Settings.ForceUnlockLockedFiles) 
    480467                    throw; 
     468 
     469                foreach (OpenHandle handle in OpenHandle.Items) 
     470                    if (handle.Path == file && handle.Close()) 
     471                    { 
     472                        GetPathADSes(list, out totalSize, file); 
     473                        return; 
     474                    } 
    481475            } 
    482476            catch (UnauthorizedAccessException e) 
Note: See TracChangeset for help on using the changeset viewer.