本文整理汇总了C#中FtpClient.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.Execute方法的具体用法?C# FtpClient.Execute怎么用?C# FtpClient.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FtpClient
的用法示例。
在下文中一共展示了FtpClient.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public static void Execute() {
using (FtpClient conn = new FtpClient()) {
FtpReply reply;
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
if (!(reply = conn.Execute("SITE CHMOD 640 FOO.TXT")).Success) {
throw new FtpCommandException(reply);
}
}
}
示例2: MakeConnection
private bool MakeConnection()
{
_client = new FtpClient {
Credentials = new NetworkCredential(_settings.Username, _settings.Password),
Host = _settings.IpAddress,
SocketKeepAlive = true
};
int port;
if(!int.TryParse(_settings.Port, out port)) {
port = 21;
_settings.Port = port.ToString(CultureInfo.InvariantCulture);
}
_client.Port = port;
SendStatusChanged("Connecting to {0}...", _settings.IpAddress);
_client.Connect();
if(!_client.IsConnected)
return false;
SendStatusChanged("Connection to {0} Established checking for Aurora...", _settings.IpAddress);
var reply = _client.Execute("SITE REVISION");
if(!reply.Success)
return false;
SendStatusChanged("Connection to Aurora revision {0} Established...", reply.Message);
return true;
}