private string FindFirstVolume() { _findHandle = Imports.FindFirstVolumeW( _buffer, _buffer.CharCapacity); if (_findHandle.IsInvalid) { WindowsError error = Error.GetLastError(); if (error == WindowsError.ERROR_FILENAME_EXCED_RANGE) { _buffer.EnsureCharCapacity(_buffer.CharCapacity + 64); return(FindFirstVolume()); } throw error.GetException(); } _buffer.SetLengthToFirstNull(); return(_buffer.ToString()); }
private void CloseHandle() { _findHandle?.Dispose(); _findHandle = null; }