Changeset 2178
- Timestamp:
- 6/18/2010 6:44:31 AM (3 years ago)
- Location:
- trunk/eraser/Eraser.Util
- Files:
-
- 2 edited
-
NativeMethods/Kernel.cs (modified) (1 diff)
-
VolumeInfo.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/NativeMethods/Kernel.cs
r2174 r2178 1167 1167 [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] 1168 1168 [return: MarshalAs(UnmanagedType.Bool)] 1169 public static extern bool GetVolumePathNamesForVolumeName( 1170 string lpszVolumeName, StringBuilder lpszVolumePathNames, uint cchBufferLength,1171 out uint lpcchReturnLength);1169 public static extern bool GetVolumePathNamesForVolumeName(string lpszVolumeName, 1170 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] char[] lpszVolumePathNames, 1171 uint cchBufferLength, out uint lpcchReturnLength); 1172 1172 1173 1173 public const int MaxPath = 260; -
trunk/eraser/Eraser.Util/VolumeInfo.cs
r2177 r2178 98 98 { 99 99 uint returnLength = 0; 100 StringBuilder pathNamesBuffer = new StringBuilder(); 101 pathNamesBuffer.EnsureCapacity(NativeMethods.MaxPath); 100 char[] pathNamesBuffer = new char[NativeMethods.MaxPath]; 102 101 while (!NativeMethods.GetVolumePathNamesForVolumeName(VolumeId, 103 pathNamesBuffer, (uint)pathNamesBuffer. Capacity, out returnLength))102 pathNamesBuffer, (uint)pathNamesBuffer.Length, out returnLength)) 104 103 { 105 104 int errorCode = Marshal.GetLastWin32Error(); … … 110 109 return result; 111 110 case Win32ErrorCode.MoreData: 112 pathNamesBuffer .EnsureCapacity((int)returnLength);111 pathNamesBuffer = new char[pathNamesBuffer.Length * 2]; 113 112 break; 114 113 default: … … 117 116 } 118 117 119 if (pathNamesBuffer.Length < returnLength) 120 pathNamesBuffer.Length = (int)returnLength; 121 pathNames = pathNamesBuffer.ToString().Substring(0, (int)returnLength); 118 pathNames = new string(pathNamesBuffer, 0, (int)returnLength); 122 119 } 123 120
Note: See TracChangeset
for help on using the changeset viewer.
