Export (0) Print
Expand All

InstallerCollection.CopyTo Method

Copies the items from the collection to an array, begining at the specified index.

Namespace:  System.Configuration.Install
Assembly:  System.Configuration.Install (in System.Configuration.Install.dll)

public void CopyTo(
	Installer[] array,
	int index
)

Parameters

array
Type: System.Configuration.Install.Installer[]

The array to copy to.

index
Type: System.Int32

The index of the array at which to paste the collection.

The following example demonstrates the CopyTo method of the InstallerCollection class. It creates AssemblyInstaller instances for MyAssembly1.exe and MyAssembly2.exe. These instances are added to a TransactedInstaller. The names of the assemblies to be installed are displayed on the console. The installation process installs both MyAssembly1.exe and MyAssembly2.exe.

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);
   }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft