public bool MoveNext() { int err_code = 0; int res = 0; if (search_handle == IntPtr.Zero) { search_handle = WinApiFS.FindFirstVolumeMountPoint(volume_guid, mount_point_buffer, mount_point_buffer_len_tchars); if (search_handle.ToInt32() == WinApiFS.INVALID_HANDLE_VALUE) { err_code = Marshal.GetLastWin32Error(); if (err_code == 18) { //no more files return(false); } else if (err_code == 21) { //device not ready return(false); } else { throw new Win32Exception(err_code); } } else { return(true); } } else { res = WinApiFS.FindNextVolumeMountPoint(search_handle, mount_point_buffer, mount_point_buffer_len_tchars); if (res == 0) { err_code = Marshal.GetLastWin32Error(); if (err_code == 18) { //no more files return(false); } else { throw new Win32Exception(err_code); } } else { return(true); } } }