资源介绍
开源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();
}
- 上一篇: TCP-IP详解(3卷全)
- 下一篇: ftp源代码C#实现