private string FindFirstVolume()
            {
                _findHandle = VolumeMethods.Imports.FindFirstVolumeW(
                    _buffer,
                    _buffer.CharCapacity);

                if (_findHandle.IsInvalid)
                {
                    WindowsError error = Errors.GetLastError();
                    if (error == WindowsError.ERROR_FILENAME_EXCED_RANGE)
                    {
                        _buffer.EnsureCharCapacity(_buffer.CharCapacity + 64);
                        return(FindFirstVolume());
                    }

                    throw Errors.GetIoExceptionForError(error);
                }

                _buffer.SetLengthToFirstNull();
                return(_buffer.ToString());
            }
Exemplo n.º 2
0
 public static extern bool FindNextVolumeW(
     FindVolumeHandle hFindVolume,
     SafeHandle lpszVolumeName,
     uint cchBufferLength);
 private void CloseHandle()
 {
     _findHandle?.Dispose();
     _findHandle = null;
 }