Esempio n. 1
0
        public static void Stub(UtilityFtpArgument utilityFtpArgument)
        {
            FtpWebRequest ftpWebRequest = null;

            ftpWebRequest = FtpWebRequestCreate(utilityFtpArgument);

            ListDirectory(ftpWebRequest);

            //DownloadFileText();
            //MakeDirectory(new Uri("ftp://127.0.0.1/MakeDirectory"));
        }
Esempio n. 2
0
        /// <summary>The entry point for the application.</summary>
        /// <param name="argv">A list of command line arguments</param>
        public static void Main(string[] argv)
        {
            bool parseCommandLineArguments;
            UtilityFtpArgument utilityFtpArgument = new UtilityFtpArgument();

            parseCommandLineArguments = Parser.ParseArgumentsWithUsage(argv, utilityFtpArgument);
            if (parseCommandLineArguments == false)
            {
                return;
            }
            Stub(utilityFtpArgument);
        }
Esempio n. 3
0
        ///<remarks>
        ///http://msdn2.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
        /// To obtain an instance of FtpWebRequest, use the Create method. You can also use the WebClient class to upload and download information from an FTP server. Using either of these approaches, when you specify a network resource that uses the FTP scheme (for example, "ftp://contoso.com") the FtpWebRequest class provides the ability to programmatically interact with FTP servers.
        /// The URI may be relative or absolute. If the URI is of the form "ftp://contoso.com/%2fpath" (%2f is an escaped '/'), then the URI is absolute, and the current directory is /path. If, however, the URI is of the form "ftp://contoso.com/path", first the .NET Framework logs into the FTP server (using the user name and password set by the Credentials property), then the current directory is set to <UserLoginDirectory>/path.
        /// You must have a valid user name and password for the server or the server must allow anonymous logon. You can specify the credentials used to connect to the server by setting the Credentials property or you can include them in the UserInfo portion of the URI passed to the Create method. If you include UserInfo information in the URI, the Credentials property is set to a new network credential with the specified user name and password information.
        ///http://msdn2.microsoft.com/en-us/library/system.uri.userinfo.aspx
        /// Uri uriAddress = new Uri ("http://*****:*****@www.contoso.com/index.htm");
        ///
        /// ftp://[email protected]:FtpPassword123*@e-comfort.ephraimtech.com:21/fFtp
        ///     Invalid URI: A port was expected because of there is a colon (':') present but the port could not be parsed.
        ///</remarks>
        public static FtpWebRequest FtpWebRequestCreate(UtilityFtpArgument utilityFtpArgument)
        {
            FtpWebRequest ftpWebRequest = null;
            Uri           uri           = null;

            try
            {
                /*
                 * UriBuilder uriBuilder = null;
                 * uriBuilder = new UriBuilder(utilityFtpArgument.Host);
                 *
                 * if (utilityFtpArgument.User != UtilityFtp.User)
                 * {
                 *  uriBuilder.UserName = utilityFtpArgument.User;
                 * }
                 * if (utilityFtpArgument.Password != UtilityFtp.Password)
                 * {
                 *  uriBuilder.Password = utilityFtpArgument.Password;
                 * }
                 * if (utilityFtpArgument.Port != UtilityFtp.Port)
                 * {
                 *  uriBuilder.Port = utilityFtpArgument.Port;
                 * }
                 * System.Console.WriteLine(uriBuilder.ToString());
                 * uri = new Uri(uriBuilder.ToString());
                 *
                 * ftpWebRequest = (FtpWebRequest)WebRequest.Create(uri);
                 */

                uri                       = new Uri(utilityFtpArgument.Host);
                ftpWebRequest             = (FtpWebRequest)WebRequest.Create(uri);
                ftpWebRequest.Credentials = new NetworkCredential(utilityFtpArgument.User, utilityFtpArgument.Password);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
            return(ftpWebRequest);
        }