文件连接管理器File Connection Manager

适用于:是 SQL Server 是 Azure 数据工厂中的 SSIS Integration Runtime 是Azure Synapse Analytics (SQL DW) APPLIES TO: yesSQL Server yesSSIS Integration Runtime in Azure Data Factory yesAzure Synapse Analytics (SQL DW)

文件连接管理器使包可以在运行时引用现有的文件或文件夹,或者创建文件或文件夹。A File connection manager enables a package to reference an existing file or folder, or to create a file or folder at run time. 例如,您可以引用 Excel 文件。For example, you can reference an Excel file. MicrosoftMicrosoft SQL ServerSQL Server Integration ServicesIntegration Services 中的某些组件使用文件中的信息来执行其工作。Certain components in MicrosoftMicrosoft SQL ServerSQL Server Integration ServicesIntegration Services use information in files to perform their work. 例如,执行 SQL 任务可以引用包含该任务执行的 SQL 语句的文件。For example, an Execute SQL task can reference a file that contains the SQL statements that the task executes. 其他组件对文件执行操作。Other components perform operations on files. 例如,文件系统任务可以引用一个文件,以便将其复制到新的位置。For example, the File System task can reference a file to copy it to a new location.

文件连接管理器的使用类型Usage Types of the File Connection Manager

文件连接管理器的 FileUsageType 属性指定如何使用文件连接。The FileUsageType property of the File connection manager specifies how the file connection is used. 文件连接管理器可以创建文件、创建文件夹、使用现有文件或使用现有文件夹。The File connection manager can create a file, create a folder, use an existing file, or use an existing folder.

下表列出了 FileUsageType的值。The following table lists the values of FileUsageType.

ReplTest1Value 描述Description
00 文件连接管理器使用现有文件。File connection manager uses an existing file.
11 文件连接管理器创建文件。File connection manager creates a file.
22 文件连接管理器使用现有文件夹。File connection manager uses an existing folder.
33 文件连接管理器创建文件夹。File connection manager creates a folder.

多个文件或文件夹连接Multiple File or Folder Connections

文件连接管理器只能引用一个文件或文件夹。The File connection manager can reference only one file or folder. 若要引用多个文件或文件夹,请使用多文件连接管理器,而不是文件连接管理器。To reference multiple files or folders, use a Multiple Files connection manager instead of a File connection manager. 有关详细信息,请参阅 Multiple Files Connection ManagerFor more information, see Multiple Files Connection Manager.

文件连接管理器的配置Configuration of the File Connection Manager

将文件连接管理器添加到包时, Integration ServicesIntegration Services 会创建将在运行时解析为文件连接的连接管理器,设置该文件连接的属性,并将该文件连接添加到包的 Connections 集合。When you add a File connection manager to a package, Integration ServicesIntegration Services creates a connection manager that will resolve to a File connection at run time, sets the File connection properties, and adds the File connection to the Connections collection of the package.

该连接管理器的 ConnectionManagerType 属性设置为 FILEThe ConnectionManagerType property of the connection manager is set to FILE.

可以用下列方式配置文件连接管理器:You can configure a File connection manager in the following ways:

  • 指定使用类型。Specify the usage type.

  • 指定文件或文件夹。Specify a file or folder.

通过在 SQL Server Data Tools (SSDT)SQL Server Data Tools (SSDT) 的“属性”窗口中指定表达式,可以设置文件连接管理器的 ConnectionString 属性。You can set the ConnectionString property for the File connection manager by specifying an expression in the Properties window of SQL Server Data Tools (SSDT)SQL Server Data Tools (SSDT). 但为了避免在使用表达式指定文件或文件夹时出现验证错误,请在“文件连接管理器编辑器” 中,为“文件/文件夹” 添加文件或文件夹路径。However, to avoid a validation error when you use an expression to specify the file or folder, in the File Connection Manager Editor, for File/Folder, add a file or folder path.

可以通过 SSISSSIS 设计器或以编程方式来设置属性。You can set properties through SSISSSIS Designer or programmatically.

有关可以在 SSISSSIS 设计器中设置的属性的详细信息,请参阅 文件连接管理器编辑器For more information about the properties that you can set in SSISSSIS Designer, see File Connection Manager Editor.

有关以编程方式配置连接管理器的信息,请参阅 ConnectionManager以编程方式添加连接项目。For information about configuring a connection manager programmatically, see ConnectionManager and Adding Connections Programmatically.

文件连接管理器编辑器File Connection Manager Editor

可以使用 “文件连接管理器编辑器” 对话框指定用于连接文件或文件夹的属性。Use the File Connection Manager Editor dialog box to specify the properties used to connect to a file or a folder.

备注

通过在 SQL Server Data Tools (SSDT)SQL Server Data Tools (SSDT)的“属性”窗口中指定表达式,可以设置文件连接管理器的 ConnectionString 属性。You can set the ConnectionString property for the File connection manager by specifying an expression in the Properties window of SQL Server Data Tools (SSDT)SQL Server Data Tools (SSDT). 但为了避免在使用表达式指定文件或文件夹时出现验证错误,请在“文件连接管理器编辑器” 中,为“文件/文件夹” 添加文件或文件夹路径。However, to avoid a validation error when you use an expression to specify the file or folder, in the File Connection Manager Editor, for File/Folder, add a file or folder path.

若要了解有关文件连接管理器的详细信息,请参阅 File Connection ManagerTo learn more about the File connection manager, see File Connection Manager.

选项Options

使用类型Usage Type
指定“文件连接管理器”是连接到现有文件或文件夹,还是创建新的文件或文件夹。 Specify whether the File Connection Manager connects to an existing file or folder or creates a new file or folder.

ReplTest1Value 描述Description
创建文件Create file 在运行时创建新文件。Create a new file at run time.
现有文件Existing file 使用现有文件。Use an existing file.
创建文件夹Create folder 在运行时创建新文件夹。Create a new folder at run time.
现有文件夹Existing folder 使用现有文件夹。Use an existing folder.

文件/文件夹File / Folder
对于“文件” ,请指定要使用的文件。If File, specify the file to use.

对于 “文件夹” ,请指定要使用的文件夹。If Folder, specify the folder to use.

“浏览”Browse
通过使用“选择文件” 或“查找文件夹” 对话框选择文件或文件夹。Select the file or folder by using the Select File or Browse for Folder dialog box.