ftp登录使用c# [英] ftp login using c#

查看:208
本文介绍了ftp登录使用c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何使用C#登录到FTP?

解决方案

a href =http://www.codeproject.com/KB/IP/ftplibrary.aspx =nofollow noreferrer> http://www.codeproject.com/KB/IP/ftplibrary.aspx



从Link获得的Snippett



  //获取基本的FtpWebRequest对象
//通用设置和安全
private FtpWebRequest GetRequest(字符串URI)
{
//创建请求
FtpWebRequest结果=(FtpWebRequest)FtpWebRequest.Create(URI );
//设置登录信息
result.Credentials = GetCredentials();
//不保持活动状态(无状态模式)
result.KeepAlive = false;
返回结果;
}

///< summary>
///从用户名/密码获取凭证
///< / summary>
private System.Net.ICredentials GetCredentials()
{
返回新的System.Net.NetworkCredential(用户名,密码);
}


How do you Login to FTP using C#?

解决方案

Here is a very nice FTP Client for C#

http://www.codeproject.com/KB/IP/ftplibrary.aspx

Snippett from Link

//Get the basic FtpWebRequest object with the
//common settings and security
private FtpWebRequest GetRequest(string URI)
{
    //create request
    FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
    //Set the login details
    result.Credentials = GetCredentials();
    //Do not keep alive (stateless mode)
    result.KeepAlive = false;
    return result;
}

/// <summary>
/// Get the credentials from username/password
/// </summary>
private System.Net.ICredentials GetCredentials()
{
    return new System.Net.NetworkCredential(Username, Password);
}

这篇关于ftp登录使用c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆