示例#1
0
        //creates ftp request that can be use again and again for the recursive function directory or file
        private FtpWebRequest StreamCreater(string path)
        {
            //creates the ftp client
            ftp ftp_client = new ftp(host, user, password);

            //creates ftp request
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(path);

            //Specify the type of ftp request
            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

            //login to the ftp server with username and password
            request.Credentials = new NetworkCredential(ftp_client.user, ftp_client.password);

            return request;
        }
示例#2
0
        private void connect_btn_Click(object sender, EventArgs e)
        {
            try
            {
                //creates the ftp client
                ftp ftp_client = new ftp("ftp://" + host_txtbx.Text, username_txtbx.Text, password_txtbx.Text);

                //sets the data members so that they can be used in the rest of the program
                host = ftp_client.host;
                user = ftp_client.user;
                password = ftp_client.password;

                //creates ftp request
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(host);

                //Specify the type of ftp request
                request.Method = WebRequestMethods.Ftp.ListDirectory;

                //login to the ftp server with username and password
                request.Credentials = new NetworkCredential(ftp_client.user, ftp_client.password);

                //establish return communication with ftp server
                FtpWebResponse response = (FtpWebResponse)request.GetResponse();

                //creates the treeview for the server
                RemoteListDirectory(remote_tv);
            }
            catch(Exception p)
            {
                MessageBox.Show("Something went wrong when trying to connect, " + p.ToString());
            }
        }