登录 注册
当前位置:主页 > 资源下载 > 13 > 使用c#编写ftplib客户端

使用c#编写ftplib客户端

  • 更新:2024-06-29 16:16:08
  • 大小:55KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:C# - 后端
  • 格式:RAR

资源介绍

开源ftp客户端 使用介绍 static void Main(string[] args) { using (FtpConnection ftp = new FtpConnection("192.168.1.209", 21, "softland", "123456")) { ftp.Open(); /* Open the FTP connection */ ftp.Login(); /* Login using previously provided credentials */ if (ftp.FileExists("CBXLic.exe")) /* check that a file exists */ ftp.GetFile("CBXLic.exe", false); /* download /incoming/file.txt as file.txt to current executing directory, overwrite if it exists */ //do some processing try { ftp.SetCurrentDirectory("/"); ftp.PutFile(@"C:\Users\zhangxiufeng\Documents\oraclelinuxdown.png", "oraclelinuxdown.png"); /* 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("/")) { Console.WriteLine(dir.Name); Console.WriteLine(dir.CreationTime); foreach (var file in dir.GetFiles()) { Console.WriteLine(file.Name+" "+file.LastWriteTime.ToString()); } } ftp.Close(); }