• 大小: 65KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-12
  • 语言: C#
  • 标签: c#  socket  ftp  子目录  

资源简介

网上东拼西凑的FTP代码,修改了下,改成能用的,也能下载指定目录的子目录。。。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Net.Sockets;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            FTPClient ftp = new FTPClient(“192.168.1.2“ ““ “administrator“ “1234“ 21);
            ftp.MkLocalDir(“c://ftp//ftp“);//如果本地无此目录,则先创建本地空目录
            ftp.Get(“远程目录“ “c://ftp//ftp“);
        }

    }
    /// 
    /// FTPClient 的摘要说明。
    /// 

    public class FTPClient
    {
        #region 构造函数
        /// 
        /// 缺省构造函数
        /// 

        public FTPClient()
        {
            strRemoteHost = ““;
            strRemotePath = ““;
            strRemoteUser = ““;
            strRemotePass = ““;
            strRemotePort = 21;
            bConnected = false;
        } /// 
        /// 构造函数
        /// 

        /// 
        /// 
        /// 
        /// 
        /// 
        public FTPClient(string remoteHost string remotePath string remoteUser string remotePass int remotePort)
        {
            strRemoteHost = remoteHost;
            strRemotePath = remotePath;
            strRemoteUser = remoteUser;
            strRemotePass = remotePass;
            strRemotePort = remotePort;
            Connect();
        }
        #endregion
        #region 登陆
        /// 
        /// FTP服务器IP地址
        /// 

        private string strRemoteHost;
        public string RemoteHost
        {
            get
            {
                return strRemoteHost;
            }
            set
            {
                strRemoteHost = value;
            }
        }
        /// 
        /// FTP服务器端口
        /// 

        private int strRemotePort;
        public int RemotePort
        {
            get
            {
                return strRemotePort;
            }
            set
            {
                strRemotePort = value;
            }
        }
        /// 
        /// 当前服务器目录
        /// 

        private string strRemotePath;
        public string RemotePath
        {
            get
            {
                return strRemotePath;
            }
            set
            {
                strRemotePath = value;
            }
        }
        /// 
        /// 登录用户账号
        /// 

        private string strRemoteUser;
        public string Re

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Code.compiled

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Code.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_WebReferences.compiled

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_WebReferences.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_-efesya9.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_05i78sau.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_146dcl0i.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_1h8grwi7.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_1_jsicn8.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_5lyulqir.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_6-z8txzi.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_9_rq534k.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_aqd2-5nb.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_cz14p-en.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_dcrosypc.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_fgqqtjrw.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_ihu0ggk2.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_ipmpocb3.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_jpkihzoh.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_jyuruo0k.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_k3ybwjkl.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_kfl6ljo7.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_kiycmzxp.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_o16tk79f.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_rkpqmfbz.dll

     文件          0  2010-07-28 13:15  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_sltgwqmv.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_so8x8bwx.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_sregt88r.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_t8eka0xj.dll

     文件          0  2010-07-28 13:16  WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\App_Web_ve2wbclz.dll

............此处省略59个文件信息

评论

共有 条评论