指定したインデックスを開始位置として、コレクションの項目を配列にコピーします。
Public Sub CopyTo( _
ByVal array() As Installer, _ ByVal index As Integer _)
[C#]
public void CopyTo(Installer[] array,intindex);
[C++]
public: void CopyTo(Installer* array[],intindex);
[JScript]
public function CopyTo(
array : Installer[],index : int);
パラメータ
- array
コピー先の配列。 - index
コレクションを貼り付ける位置を示す、配列内のインデックス。
使用例
[Visual Basic, C#, C++] InstallerCollection クラスの CopyTo メソッドの例を次に示します。これは MyAssembly1.exe
および MyAssembly2.exe
の AssemblyInstaller インスタンスを作成します。これらのインスタンスは、 TransactedInstaller に追加されます。インストールされるアセンブリの名前が、コンソールに表示されます。インストール プロセスによって、 MyAssembly1.exe
と MyAssembly2.exe
の両方がインストールされます。
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
[C#]
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);
}
}
[C++]
TransactedInstaller* myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller* myAssemblyInstaller;
InstallContext* myInstallContext;
// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = new AssemblyInstaller(S"MyAssembly1.exe", 0);
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add(myAssemblyInstaller);
// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = new AssemblyInstaller(S"MyAssembly2.exe", 0);
// 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(S"Printing all assemblies to be installed -");
for (int i = 0; i < myInstallers->Length; i++) {
if (dynamic_cast<AssemblyInstaller*>(myInstallers[i])) {
Console::WriteLine(S"{0} {1}", __box(i + 1),
__try_cast<AssemblyInstaller*>(myInstallers)->Path);
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
InstallerCollection クラス | InstallerCollection メンバ | System.Configuration.Install 名前空間