Changeset 2280


Ignore:
Timestamp:
1/1/2011 1:27:58 AM (3 years ago)
Author:
lowjoel
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0/Eraser.Util/StreamInfo.cs

    r2251 r2280  
    176176            get 
    177177            { 
    178                 long fileSize; 
    179                 using (SafeFileHandle handle = fileHandle) 
    180                     if (KernelApi.NativeMethods.GetFileSizeEx(handle, out fileSize)) 
    181                         return fileSize; 
     178                try 
     179                { 
     180                    long fileSize; 
     181                    using (SafeFileHandle handle = fileHandle) 
     182                        if (KernelApi.NativeMethods.GetFileSizeEx(handle, out fileSize)) 
     183                            return fileSize; 
     184                } 
     185                catch (UnauthorizedAccessException) 
     186                { 
     187                    //Swallow: we just return 0 in this situation as there's nothing we can 
     188                    //do about this error. 
     189                } 
    182190 
    183191                return 0; 
Note: See TracChangeset for help on using the changeset viewer.