Beispiel #1
0
        /// <summary>
        /// Invokes <c>FtpFindFirstFile</c>, handling error conditions. Returns <c>false</c> if there are no more matching files.
        /// </summary>
        /// <param name="find">The find handle.</param>
        /// <param name="next">On return, the details for the first matching remote file/directory.</param>
        /// <returns><c>true</c> if another file was found; <c>false</c> if there are no more matching files.</returns>
        public static bool FtpFindNextFile(SafeInternetHandle find, out FtpDirectoryEntry next)
        {
            next = new FtpDirectoryEntry();
            FtpWin32FindData data;

            if (!DoFtpFindNextFile(find, out data))
            {
                if (Marshal.GetLastWin32Error() == ERROR_NO_MORE_FILES)
                {
                    return(false);
                }

                throw GetLastInternetException();
            }

            next = data.ToFtpDirectoryEntry();
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Invokes <c>FtpFindFirstFile</c>, handling error conditions. Returns <c>false</c> if there are no matching files.
        /// </summary>
        /// <param name="connect">The internet connection handle.</param>
        /// <param name="search">The search string, which may include wildcards and/or directory information.</param>
        /// <param name="flags">Additional flags for this action.</param>
        /// <param name="first">On return, the details for the first matching remote file/directory.</param>
        /// <param name="find">On return, the find handle.</param>
        /// <returns><c>true</c> if there is at least one matching file; <c>false</c> otherwise.</returns>
        public static bool FtpFindFirstFile(SafeInternetHandle connect, string search, FtpHandle.FindFilesFlags flags, out FtpDirectoryEntry first, out SafeInternetHandle find)
        {
            FtpWin32FindData data;

            find = DoFtpFindFirstFile(connect, search, out data, flags, (IntPtr)1);
            if (find.IsInvalid)
            {
                if (Marshal.GetLastWin32Error() == ERROR_NO_MORE_FILES)
                {
                    first = new FtpDirectoryEntry();
                    return(false);
                }

                throw GetLastInternetException();
            }

            first = data.ToFtpDirectoryEntry();
            return(true);
        }