示例#1
0
 private static extern SafeInternetHandle DoFtpFindFirstFile(SafeInternetHandle hConnect, string lpszSearchFile, out FtpWin32FindData lpFindFileData, FtpHandle.FindFilesFlags dwFlags, IntPtr dwContext);
示例#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);
        }