本文整理汇总了C#中System.Net.FtpWebRequest.EnableSsl属性的典型用法代码示例。如果您正苦于以下问题:C# FtpWebRequest.EnableSsl属性的具体用法?C# FtpWebRequest.EnableSsl怎么用?C# FtpWebRequest.EnableSsl使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Net.FtpWebRequest
的用法示例。
在下文中一共展示了FtpWebRequest.EnableSsl属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListFilesOnServerSsl
public static bool ListFilesOnServerSsl(Uri serverUri)
{
// The serverUri should start with the ftp:// scheme.
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return false;
}
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.EnableSsl = true;
// Get the ServicePoint object used for this request, and limit it to one connection.
// In a real-world application you might use the default number of connections (2),
// or select a value that works best for your application.
ServicePoint sp = request.ServicePoint;
Console.WriteLine("ServicePoint connections = {0}.", sp.ConnectionLimit);
sp.ConnectionLimit = 1;
FtpWebResponse response = (FtpWebResponse) request.GetResponse();
Console.WriteLine("The content length is {0}", response.ContentLength);
// The following streams are used to read the data returned from the server.
Stream responseStream = null;
StreamReader readStream = null;
try
{
responseStream = response.GetResponseStream();
readStream = new StreamReader(responseStream, System.Text.Encoding.UTF8);
if (readStream != null)
{
// Display the data received from the server.
Console.WriteLine(readStream.ReadToEnd());
}
Console.WriteLine("List status: {0}",response.StatusDescription);
}
finally
{
if (readStream != null)
{
readStream.Close();
}
if (response != null)
{
response.Close();
}
}
Console.WriteLine("Banner message: {0}",
response.BannerMessage);
Console.WriteLine("Welcome message: {0}",
response.WelcomeMessage);
Console.WriteLine("Exit message: {0}",
response.ExitMessage);
return true;
}