當前位置: 首頁>>代碼示例>>C#>>正文


C# FtpWebRequest.EnableSsl屬性代碼示例

本文整理匯總了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;
       }
開發者ID:.NET開發者,項目名稱:System.Net,代碼行數:59,代碼來源:FtpWebRequest.EnableSsl


注:本文中的System.Net.FtpWebRequest.EnableSsl屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。