Пример #1
0
            public bool MoveNext()
            {
                int err_code = 0;
                int res      = 0;

                if (search_handle == IntPtr.Zero)
                {
                    search_handle = WinApiFS.FindFirstVolume(volume_guid_buffer, volume_guid_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
                        {
                            throw new Win32Exception(err_code);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    res = WinApiFS.FindNextVolume(search_handle, volume_guid_buffer, volume_guid_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);
                    }
                }
            }