示例#1
0
            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());
            }
示例#2
0
 private void CloseHandle()
 {
     _findHandle?.Dispose();
     _findHandle = null;
 }