Freigeben über


InstallerCollection.CopyTo-Methode

Kopiert die Elemente aus der Auflistung in ein Array, beginnend am angegebenen Index.

Namespace: System.Configuration.Install
Assembly: System.Configuration.Install (in system.configuration.install.dll)

Syntax

'Declaration
Public Sub CopyTo ( _
    array As Installer(), _
    index As Integer _
)
'Usage
Dim instance As InstallerCollection
Dim array As Installer()
Dim index As Integer

instance.CopyTo(array, index)
public void CopyTo (
    Installer[] array,
    int index
)
public:
void CopyTo (
    array<Installer^>^ array, 
    int index
)
public void CopyTo (
    Installer[] array, 
    int index
)
public function CopyTo (
    array : Installer[], 
    index : int
)

Parameter

  • array
    Das Array, in das kopiert werden soll.
  • index
    Der Index des Arrays, an dem die Auflistung eingefügt werden soll.

Beispiel

Das folgende Beispiel veranschaulicht die CopyTo-Methode der InstallerCollection-Klasse. Dabei werden AssemblyInstaller-Instanzen für MyAssembly1.exe und MyAssembly2.exe erstellt. Diese Instanzen werden einem TransactedInstaller hinzugefügt. Die Namen der zu installierenden Assemblys werden auf der Konsole angezeigt. Beim Installationsvorgang werden sowohl MyAssembly1.exe als auch MyAssembly2.exe installiert.

Dim myTransactedInstaller As New TransactedInstaller()
Dim myAssemblyInstaller As AssemblyInstaller
Dim myInstallContext As InstallContext

' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly1.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly2.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

Dim myInstallers(myTransactedInstaller.Installers.Count-1) As Installer

myTransactedInstaller.Installers.CopyTo(myInstallers, 0)
' Print the assemblies to be installed.
Console.WriteLine("Printing all assemblies to be installed -")
Dim i As Integer
For i = 0 To myInstallers.Length - 1
   If myInstallers(i).GetType().Equals(GetType(AssemblyInstaller)) Then
      Console.WriteLine("{0} {1}", i + 1, CType(myInstallers(i), AssemblyInstaller).Path)
   End If
Next i
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller =
   new AssemblyInstaller("MyAssembly1.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller =
   new AssemblyInstaller("MyAssembly2.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);
     
Installer[] myInstallers =
   new Installer[myTransactedInstaller.Installers.Count];

myTransactedInstaller.Installers.CopyTo(myInstallers, 0);
// Print the assemblies to be installed.
Console.WriteLine("Printing all assemblies to be installed -");
for(int i = 0; i < myInstallers.Length; i++)
{
   if((myInstallers[i].GetType()).Equals(typeof(AssemblyInstaller)))
   {
      Console.WriteLine("{0} {1}", i + 1,
         ((AssemblyInstaller)myInstallers[i]).Path);
   }
}
TransactedInstaller^ myTransactedInstaller = gcnew TransactedInstaller;
AssemblyInstaller^ myAssemblyInstaller;
InstallContext^ myInstallContext;

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller =
   gcnew AssemblyInstaller( "MyAssembly1.exe",nullptr );

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add( myAssemblyInstaller );

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller =
   gcnew AssemblyInstaller( "MyAssembly2.exe",nullptr );

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add( myAssemblyInstaller );

array<Installer^>^ myInstallers =
   gcnew array<Installer^>(myTransactedInstaller->Installers->Count);

myTransactedInstaller->Installers->CopyTo( myInstallers, 0 );
// Print the assemblies to be installed.
Console::WriteLine( "Printing all assemblies to be installed -" );
for ( int i = 0; i < myInstallers->Length; i++ )
{
   if ( dynamic_cast<AssemblyInstaller^>( myInstallers[ i ] ) )
   {
      Console::WriteLine( "{0} {1}", i + 1, ( (AssemblyInstaller^)( myInstallers[ i ]) )->Path );
   }
}
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;

// Create an instance of 'AssemblyInstaller' 
// that installs 'MyAssembly1.exe'.
myAssemblyInstaller = new AssemblyInstaller("MyAssembly1.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.get_Installers().Add(myAssemblyInstaller);

// Create an instance of 'AssemblyInstaller' 
// that installs 'MyAssembly2.exe'.
myAssemblyInstaller = new AssemblyInstaller("MyAssembly2.exe", null);

// Add the instance of 'AssemblyInstaller' 
//to the 'TransactedInstaller'.
myTransactedInstaller.get_Installers().Add(myAssemblyInstaller);

Installer myInstallers[] = 
    new Installer[myTransactedInstaller.get_Installers().get_Count()];
myTransactedInstaller.get_Installers().CopyTo(myInstallers, 0);

// Print the assemblies to be installed.
Console.WriteLine("Printing all assemblies to be installed -");
for (int i = 0; i < myInstallers.length; i++) {
    if (myInstallers.get_Item(i).GetType().
        Equals(AssemblyInstaller.class.ToType())) {
        Console.WriteLine("{0} {1}", System.Convert.ToString(i + 1), 
            ((AssemblyInstaller)(myInstallers.get_Item(i))).get_Path());
    }
}

.NET Framework-Sicherheit

  • Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter .

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

InstallerCollection-Klasse
InstallerCollection-Member
System.Configuration.Install-Namespace