| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
11年前发布

C#的FTP类库:C# FTP Library

这个类库对wininet.dll进行封装提供了 FTP 功能。使用C#语言和.NET框架建立一个与FTP服务器有效的交互方式。示例代码:

  using (FtpConnection ftp = new FtpConnection("ftpserver", "username", "password"))              {                                    ftp.Open(); /* Open the FTP connection */                  ftp.Login(); /* Login using previously provided credentials */                    if (ftp.DirectoryExists("/incoming")) /* check that a directory exists */                      ftp.SetCurrentDirectory("/incoming"); /* change current directory */                    if (ftp.FileExists("/incoming/file.txt"))  /* check that a file exists */                      ftp.GetFile("/incoming/file.txt", false); /* download /incoming/file.txt as file.txt to current executing directory, overwrite if it exists */                    //do some processing                    try                  {                      ftp.SetCurrentDirectory("/outgoing");                      ftp.PutFile(@"c:\localfile.txt", "file.txt"); /* upload c:\localfile.txt to the current ftp directory as file.txt */                  }                  catch (FtpException e)                  {                      Console.WriteLine(String.Format("FTP Error: {0} {1}", e.ErrorCode, e.Message));                  }                    foreach(var dir in ftp.GetDirectories("/incoming/processed"))                  {                      Console.WriteLine(dir.Name);                      Console.WriteLine(dir.CreationTime);                      foreach (var file in dir.GetFiles())                      {                          Console.WriteLine(file.Name);                          Console.WriteLine(file.LastAccessTime);                      }                  }              }

项目主页:http://www.open-open.com/lib/view/home/1371527050218

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1371527050218.html
FTP 网络工具包