ConnectionInfo.FileName 属性

定义

返回作为连接的数据源的文件的名称。 此值为只读的。

public:
 property System::String ^ FileName { System::String ^ get(); };
public string FileName { get; }
member this.FileName : string
Public ReadOnly Property FileName As String

属性值

包含连接的源数据的文件名的字符串。

示例

下面的代码示例创建一个 Application 对象,循环访问计算机上的默认连接,然后列出每个连接的属性。 在此示例中,它 FileName 显示为“C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DtsConn.dll”。

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

namespace ConnInfoTest  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application dtsApplication = new Application();  
            ConnectionInfos connectionInfos = dtsApplication.ConnectionInfos;  

            foreach (ConnectionInfo connInfo in connectionInfos)  
            {  
                Console.WriteLine(connInfo.ConnectionContact);  
                Console.WriteLine(connInfo.ConnectionType);  
                Console.WriteLine(connInfo.CreationName);  
                Console.WriteLine(connInfo.Description);  
                Console.WriteLine(connInfo.FileName);  
                //Console.WriteLine(connInfo.FileNameVersionString);  
                Console.WriteLine(connInfo.IconFile);  
                Console.WriteLine(connInfo.IconResource);  
                Console.WriteLine(connInfo.ID);  
                Console.WriteLine(connInfo.Name);  
                Console.WriteLine(connInfo.UITypeName);  
            }  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace ConnInfoTest  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim dtsApplication As Application =  New Application()   
            Dim connectionInfos As ConnectionInfos =  dtsApplication.ConnectionInfos   

            Dim connInfo As ConnectionInfo  
            For Each connInfo In connectionInfos  
                Console.WriteLine(connInfo.ConnectionContact)  
                Console.WriteLine(connInfo.ConnectionType)  
                Console.WriteLine(connInfo.CreationName)  
                Console.WriteLine(connInfo.Description)  
                Console.WriteLine(connInfo.FileName)  
                'Console.WriteLine(connInfo.FileNameVersionString)  
                Console.WriteLine(connInfo.IconFile)  
                Console.WriteLine(connInfo.IconResource)  
                Console.WriteLine(connInfo.ID)  
                Console.WriteLine(connInfo.Name)  
                Console.WriteLine(connInfo.UITypeName)  
            Next  
        End Sub  
    End Class  
End Namespace  

示例输出:

Microsoft Corporation

FILE

DTS.ConnectionManagerFile.1

Connection Manager for Files

C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DtsConn.dll

C:\Program Files\Microsoft SQL Server\100\DTS\Binn\DtsConn.dll

0

{41F5EFE4-E91A-4EB0-BF10-D40FD48B3C03}

DTS Connection Manager for Files

Microsoft.DataTransformationServices.Design.SingleFileConnectionManagerUI,

Microsoft.DataTransformationServices.Design, Version=10.0.000.0,

Culture=neutral, PublicKeyToken=89845dcd8080cc91

适用于