/// <summary>
/// Ftp图片上传
///作者:金双林
///时间:2016-07-28
/// </summary>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
/// Ftp图片上传
///作者:金双林
///时间:2016-07-28
/// </summary>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
FileDown("qxw1192990199.my3w.com", "test", "E://jinsl.png", "ftp登录名", "ftp密码");
}
/// <summary>
/// edtFtpnet上传
/// </summary>
/// <param name="ftpServerIP">ftp地址</param>
/// <param name="ftpRemotePath">ftp操作的路径</param>
/// <param name="fileName">上传文件路径</param>
/// <param name="ftpUserID">ftp登录名</param>
/// <param name="ftpPassword">ftp登录密码</param>
public void FileDown(string ftpServerIP, string ftpRemotePath, string fileName, string ftpUserID, string ftpPassword)
{
using (var conn = new FTPConnection
{
ServerAddress = ftpServerIP,
ServerDirectory = ftpRemotePath,
UserName = ftpUserID,
Password = ftpPassword,
CommandEncoding = Encoding.GetEncoding("GBK")
})
{
string ftpfilename = Path.GetFileNameWithoutExtension(fileName); //文件名
string filesuffix = Path.GetExtension(fileName); //后缀名
conn.Connect();
//conn.CreateDirectory("test"); //创建test文件夹
//conn.UploadFile("E://新建文本文档.txt", "testUp.txt"); //把"新建文本文档.txt"内容复制到testUp.txt中
conn.UploadFile(fileName, ftpfilename + filesuffix); //上传文件
}
}