zoukankan      html  css  js  c++  java
  • Midapex网络开发库v2.2(更新主题:使用C#实现的FTP客户端)

    工程:Midapex网络开发库
    授权方式:GPL V3
    版本:v2.2
    运行平台:.NET 2.0
    IDE:Visual Sutido 2008
    (C)2008 Midapex All Rights Reserved.

    工程下载地址:https://files.cnblogs.com/dyj057/MidapexNetLibv2.2.rar

    v2.2功能特点:
        1.添加FtpClient的功能实现,通过该类可以实现大多数的FTP文件操作,配合FtpServer实现完整的文件传输功能。
        2.整合了Midapex.dll和Midapx.Net.dll,只需要引入一次组件,更方便使用。

    v2.1功能特点:
        1.添加FtpServer的功能实现。
        2.二次开发功能,可以很容易的实现内嵌的FTP Server,实现文件的传输功能。

    v2.0功能特点:
        1.使用异步Socket,它的内部使用IOCP实现,性能优越。
        2.实现通讯中的心跳功能,能即时发现处理‘死连接’现象。
        3.通过自定义报文或者文本字段实现通讯数据的自动分段。
        4.支持数据加密传输。
        5.支持Mono,可以跨平台使用该库。
        6.通过模板编程,实现各个功能模块灵活组装使用。
        7.内附完整开发指南。

    具体内容请参看本博客其它内容。
    PS:这两天就写Ftp client代码了,累就一个字。。。。希望大家满意。

    Ftp Client示例代码:

    class Program
        {
            
    static void Main(string
    [] args)
            {
                Trace.Listeners.Add(
    new
     ConsoleTraceListener());
                TimeCounter counter 
    = new
     TimeCounter();
                counter.Start();

                
    try

                {
                    
    //设置服务器的地址,端口,登陆帐号
                    using (FtpClient client = new FtpClient("127.0.0.1"21"ftp""ftp"))
                    {
                            
    //先连接服务器

                            client.Connect();
                            
    //然后发送登陆信息

                            client.Login();
                            client.GetCurrentDir();
                            client.ChangeDir(
    "/"
    );

                            
    //列出根目录下的文件或目录

                            List<FtpPathItem> items = client.List();
                            
    foreach (FtpPathItem item in
     items)
                            {
                                
    if
     (item.IsFile)
                                    Console.WriteLine(
    "<FILE> " +
     item.Name);
                                
    else

                                    Console.WriteLine(
    "<DIR> " + item.Name);
                            }

                            
    //生成一个新的随机名称目录 

                            string newDir = ShortGuid.Create().ToShortString();
                            client.CreateDir(newDir);
                            client.ChangeDir(newDir);

                            Console.WriteLine(
    "CURRENT DIR:" +
     client.CurrentDir);

                            
    string remoteFile = "nba_upload.jpg"
    ;
                            
    string localFile = "nba.jpg"
    ;

                            
    //上传文件

                            Console.WriteLine("UPLOAD  FILE:" + localFile);
                            client.Upload(remoteFile, localFile);

                            
    //同步下载文件

                            localFile = "nba_down_sync.jpg";
                            Console.WriteLine(
    "SYNC DOWNLOAD  FILE:" +
     localFile);
                            client.Download(remoteFile, localFile);

                            
    //退到上一级目录

                            client.ChangeDir("..");

                            
    //删除刚才创建的文件

                            client.DeleteFile(newDir + "/" + remoteFile);
                            
    //生成一个新的随机目录名称,然后重命名刚创建的目录

                            string newDir2 = ShortGuid.Create().ToShortString();
                            client.RenamePath(newDir, newDir2);

                            
    //删除刚才创建的目录

                            client.DeleteDir(newDir2);

                            
    //断开与服务器的连接

                            client.Disconnect();
                            counter.Stop();
                            Console.WriteLine(
    "RUN TIME:" + counter.Milliseconds + "ms"
    );
                            Console.WriteLine(
    "Press enter key to exit."
    );
                            Console.ReadLine();
                        }
                }
                
    catch
     (System.Exception e)
                {
                    NetDebuger.PrintErrorMessage(e.ToString());
                    Console.ReadLine();
                }
            }
        }
  • 相关阅读:
    Jzoj4822 完美标号
    Jzoj4822 完美标号
    Jzoj4792 整除
    Jzoj4792 整除
    Educational Codeforces Round 79 A. New Year Garland
    Good Bye 2019 C. Make Good
    ?Good Bye 2019 B. Interesting Subarray
    Good Bye 2019 A. Card Game
    力扣算法题—088扰乱字符串【二叉树】
    力扣算法题—086分隔链表
  • 原文地址:https://www.cnblogs.com/dyj057/p/1160392.html
Copyright © 2011-2022 走看看