Changeset 2281


Ignore:
Timestamp:
01/01/11 01:33:34 (4 years ago)
Author:
lowjoel
Message:

Forward-port from Eraser 6.0: Don't allow the UnauthorizedAccessException? to propagate up the stack; this is a problem which getting the length of the file may trigger, and for such situations, return 0.

Location:
trunk/eraser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser

  • trunk/eraser/Eraser.Util/StreamInfo.cs

    r2208 r2281  
    164164            get 
    165165            { 
    166                 long fileSize; 
    167                 using (SafeFileHandle handle = OpenHandle( 
    168                     FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.None)) 
     166                try 
    169167                { 
    170                     if (NativeMethods.GetFileSizeEx(handle, out fileSize)) 
    171                         return fileSize; 
     168                    using (SafeFileHandle handle = OpenHandle( 
     169                        FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.None)) 
     170                    { 
     171                        long fileSize; 
     172                        if (NativeMethods.GetFileSizeEx(handle, out fileSize)) 
     173                            return fileSize; 
     174                    } 
     175                } 
     176                catch (UnauthorizedAccessException) 
     177                { 
     178                    //Swallow: we just return 0 in this situation as there's nothing we can 
     179                    //do about this error. 
    172180                } 
    173181 
Note: See TracChangeset for help on using the changeset viewer.