FtpClientConnection.UsePassiveMode 属性

定义

获取或设置一个布尔值,该值指示任务是否以被动模式发送和接收文件。

public:
 property bool UsePassiveMode { bool get(); void set(bool value); };
public bool UsePassiveMode { get; set; }
member this.UsePassiveMode : bool with get, set
Public Property UsePassiveMode As Boolean

属性值

如果任务以被动模式发送和接收文件,则为 true。 如果任务正在使用活动模式,则为 false。

示例

创建 FTP 客户端连接的最常见方法是使用 ConnectionManager. InnerObject包含该连接,以及该ConnectionManager连接包含的特定连接的所有属性均可通过Properties集合访问。 下面的代码示例演示如何使用连接管理器创建 FTP 连接,并使用集合设置属性 Properties

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;  

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class mySqlServer_Sample  
    {  
        static void Main(string[] args)  
        {  
            Package pkg = new Package();  
            FtpClientConnection ftp = null;  
            Connections conns = pkg.Connections;  
            ConnectionManager cm = conns.Add("FTP");  

            // Display the default values of the FTP connection properties.  
            // Some properties are not shown as they are write-only.  
            Console.WriteLine("ChunkSize:      {0}", cm.Properties["ChunkSize"].GetValue(cm));  
            Console.WriteLine("Retries:        {0}", cm.Properties["Retries"].GetValue(cm));  
            Console.WriteLine("ServerName:     {0}", cm.Properties["ServerName"].GetValue(cm));  
            Console.WriteLine("ServerPort:     {0}", cm.Properties["ServerPort"].GetValue(cm));  
            Console.WriteLine("ServerUserName: {0}", cm.Properties["ServerUserName"].GetValue(cm));  
            Console.WriteLine("Timeout:        {0}", cm.Properties["Timeout"].GetValue(cm));  
            Console.WriteLine("UsePassiveMode: {0}",cm.Properties["UsePassiveMode"].GetValue(cm));  

            Console.WriteLine();  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask  

Namespace Microsoft.SqlServer.SSIS.Samples  
    Class mySqlServer_Sample  
        Shared  Sub Main(ByVal args() As String)  
            Dim pkg As Package =  New Package()   
            Dim ftp As FtpClientConnection =  Nothing   
            Dim conns As Connections =  pkg.Connections   
            Dim cm As ConnectionManager =  conns.Add("FTP")   

            ' Display the default values of the FTP connection properties.  
            ' Some properties are not shown as they are write-only.  
            Console.WriteLine("ChunkSize:      {0}", cm.Properties("ChunkSize").GetValue(cm))  
            Console.WriteLine("Retries:        {0}", cm.Properties("Retries").GetValue(cm))  
            Console.WriteLine("ServerName:     {0}", cm.Properties("ServerName").GetValue(cm))  
            Console.WriteLine("ServerPort:     {0}", cm.Properties("ServerPort").GetValue(cm))  
            Console.WriteLine("ServerUserName: {0}", cm.Properties("ServerUserName").GetValue(cm))  
            Console.WriteLine("Timeout:        {0}", cm.Properties("Timeout").GetValue(cm))  
            Console.WriteLine("UsePassiveMode: {0}",cm.Properties("UsePassiveMode").GetValue(cm))  

            Console.WriteLine()  
        End Sub  
    End Class  
End Namespace  

示例输出:

区块:1

重试次数:5

服务器名称:

ServerPort:21

ServerUserName:

超时:60

UsePassiveMode: False

注解

此属性的默认值为 False。 有关主动模式与被动模式的详细信息,请参阅 FTP 任务

适用于