Compartir a través de


Package.ExportConfigurationFile Method

Creates an XML file that contains all deployable variables in the package.

Espacio de nombres: Microsoft.SqlServer.Dts.Runtime
Ensamblado: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

Sintaxis

'Declaración
Public Sub ExportConfigurationFile ( _
    str As String _
)
public void ExportConfigurationFile (
    string str
)
public:
void ExportConfigurationFile (
    String^ str
)
public void ExportConfigurationFile (
    String str
)
public function ExportConfigurationFile (
    str : String
)

Parámetros

  • str
    The path to the configuration file.

Notas

You can edit the configuration file and change the values for the computer-dependent variables. Each time the package is deployed to a different computer, it will use the computer-dependent variables on that computer when executing. For more information, see Crear configuraciones de paquetes.

Ejemplo

The following example creates a new package, sets EnableConfigurations to true, and sets the ExportConfigurationFile property. The example then adds a new configuration to the package and sets the value of the ConfigurationString, ConfigurationType, and PackagePath.

static void Main(string[] args)
        {
            // Create a package and set two properties.
            Package pkg = new Package();
            pkg.EnableConfigurations = true;
            pkg.ExportConfigurationFile(@"C:\conf.xml");

            // Create a variable object and add it to the 
            // package Variables collection.
            Variable varPkg = pkg.Variables.Add("var", false, "", 100);
            varPkg.Value = 1;
            string packagePathToVariable = varPkg.GetPackagePath();

            // Create a configuration object and add it to the 
           // package configuration collection
            Configuration config = pkg.Configurations.Add();

           // Set properties on the configuration object.
            config.ConfigurationString = "conf.xml";
            config.ConfigurationType = DTSConfigurationType.ConfigFile;
            config.PackagePath = packagePathToVariable;

            //save the package and its configuration
            Application app = new Application();
            app.SaveToXml(@"c:\pkg.xml", pkg, null);
            
            //Reload the package
            Package p1 = app.LoadPackage(@"c:\pkg.xml", null);
            //Review its Variables collection
            Console.WriteLine("The value of variable VAR = " + p1.Variables["var"].Value);
        }
Shared  Sub Main(ByVal args() As String)
            ' Create a package and set two properties.
            Dim pkg As Package =  New Package() 
            pkg.EnableConfigurations = True
            pkg.ExportConfigurationFile("C:\conf.xml")
 
            ' Create a variable object and add it to the 
            ' package Variables collection.
            Dim varPkg As Variable =  pkg.Variables.Add("var",False,"",100) 
            varPkg.Value = 1
            Dim packagePathToVariable As String =  varPkg.GetPackagePath() 
 
            ' Create a configuration object and add it to the 
           ' package configuration collection
            Dim config As Configuration =  pkg.Configurations.Add() 
 
           ' Set properties on the configuration object.
            config.ConfigurationString = "conf.xml"
            config.ConfigurationType = DTSConfigurationType.ConfigFile
            config.PackagePath = packagePathToVariable
 
            'save the package and its configuration
            Dim app As Application =  New Application() 
            app.SaveToXml("c:\pkg.xml", pkg, Nothing)
 
            'Reload the package
            Dim p1 As Package =  app.LoadPackage("c:\pkg.xml",Nothing) 
            'Review its Variables collection
            Console.WriteLine("The value of variable VAR = " + p1.Variables("var").Value)
End Sub

Sample Output:

The value of variable VAR = 1

Seguridad para subprocesos

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Plataformas

Plataformas de desarrollo

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Plataformas de destino

Para obtener una lista de las plataformas compatibles, vea Requisitos de hardware y software para instalar SQL Server 2005.

Vea también

Referencia

Package Class
Package Members
Microsoft.SqlServer.Dts.Runtime Namespace