Changeset 2198 for trunk/eraser


Ignore:
Timestamp:
6/19/2010 2:09:11 AM (4 years ago)
Author:
lowjoel
Message:

Fixed UnauthorizedAccessException? when erasing files from an NTFS volume under Windows 7. Fixes regression in r2189

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util/NtfsApi.cs

    r2189 r2198  
    5252        public static long GetMftRecordSegmentSize(VolumeInfo volume) 
    5353        { 
    54             NativeMethods.NTFS_VOLUME_DATA_BUFFER? volumeData = GetNtfsVolumeData(volume); 
    55             if (volumeData == null) 
     54            try 
     55            { 
     56                return GetNtfsVolumeData(volume).BytesPerFileRecordSegment; 
     57            } 
     58            catch (UnauthorizedAccessException) 
     59            { 
    5660                return Math.Min(volume.ClusterSize, 1024); 
    57  
    58             return volumeData.Value.BytesPerFileRecordSegment; 
     61            } 
    5962        } 
    6063 
     
    6770        /// file system structures for the volume, or null if the data could not be 
    6871        /// retrieved.</returns> 
    69         internal static NativeMethods.NTFS_VOLUME_DATA_BUFFER? GetNtfsVolumeData(VolumeInfo volume) 
     72        internal static NativeMethods.NTFS_VOLUME_DATA_BUFFER GetNtfsVolumeData(VolumeInfo volume) 
    7073        { 
    7174            using (FileStream stream = volume.Open(FileAccess.Read, FileShare.ReadWrite, 
Note: See TracChangeset for help on using the changeset viewer.