ConfigurationManager.OpenExeConfigurationとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ConfigurationManager.OpenExeConfigurationの意味・解説 

ConfigurationManager.OpenExeConfiguration メソッド (ConfigurationUserLevel)

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在のアプリケーション構成ファイルConfiguration オブジェクトとして開きます

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

Public Shared Function OpenExeConfiguration
 ( _
    userLevel As ConfigurationUserLevel _
) As Configuration
Dim userLevel As ConfigurationUserLevel
Dim returnValue As Configuration

returnValue = ConfigurationManager.OpenExeConfiguration(userLevel)
public static Configuration OpenExeConfiguration
 (
    ConfigurationUserLevel userLevel
)
public:
static Configuration^ OpenExeConfiguration (
    ConfigurationUserLevel userLevel
)
public static Configuration OpenExeConfiguration
 (
    ConfigurationUserLevel userLevel
)
public static function OpenExeConfiguration
 (
    userLevel : ConfigurationUserLevel
) : Configuration

パラメータ

userLevel

構成を開く対象となる ConfigurationUserLevel。

戻り値
Configuration オブジェクト

例外例外
例外種類条件

ConfigurationErrorsException

構成ファイル読み込むことができませんでした

解説解説

クライアント アプリケーションでは、すべてのユーザー適用するグローバル構成個々ユーザー適用する個別構成、およびローミング ユーザー適用する構成使用しますuserLevel パラメータは、構成ファイルユーザー レベルではない (構成ファイルアプリケーションと同じディレクトリにある)、またはユーザー単位レベル (構成ファイルユーザー レベルで決まるアプリケーション設定パスにある) のどちらであるかを示すことによって、開く構成ファイルの場所を決定します

userLevel次の値のいずれかを渡すことによって、取得する構成指定します

使用例使用例

OpenExeConfiguration メソッド使用してカスタム構成セクション変更する方法次のコード例示します

 ' Modify a custom section. Show how to use the
 ' OpenExeConfiguration(ConfigurationUserLevel) method.
Shared Sub ModifyCustomSection()
   ' Get the application configuration file.
     Dim config As System.Configuration.Configuration
 = _
     ConfigurationManager.OpenExeConfiguration( _
     ConfigurationUserLevel.None)
   
   Console.WriteLine(config.FilePath)
   
     Dim custSection As CustomSection = _
     config.Sections(customSectionName)
   
   custSection.FileName = "newName.txt"
   custSection.MaxIdleTime = New TimeSpan(0, 15, 0)
   custSection.MaxUsers = custSection.MaxUsers + 10
   
   If Not custSection.ElementInformation.IsLocked
 Then
      config.Save()
   Else
      Console.WriteLine("Section was locked, could not update.")
   End If
End Sub 'ModifyCustomSection
// Modify a custom section. Show how to use the
// OpenExeConfiguration(ConfigurationUserLevel) method.
static void ModifyCustomSection()
{
    // Get the application configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    Console.WriteLine(config.FilePath);

    CustomSection custSection =
       config.Sections[customSectionName] as CustomSection;

    custSection.FileName = "newName.txt";
    custSection.MaxIdleTime = new TimeSpan(0, 15, 0);
    custSection.MaxUsers = custSection.MaxUsers + 10;

    if (!custSection.ElementInformation.IsLocked)
        config.Save();
    else
        Console.WriteLine("Section was locked, could not update.");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ConfigurationManager.OpenExeConfiguration メソッド (String)

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定したクライアント構成ファイルConfiguration オブジェクトとして開きます

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

Public Shared Function OpenExeConfiguration
 ( _
    exePath As String _
) As Configuration
Dim exePath As String
Dim returnValue As Configuration

returnValue = ConfigurationManager.OpenExeConfiguration(exePath)
public static Configuration OpenExeConfiguration
 (
    string exePath
)
public:
static Configuration^ OpenExeConfiguration (
    String^ exePath
)
public static Configuration OpenExeConfiguration
 (
    String exePath
)
public static function OpenExeConfiguration
 (
    exePath : String
) : Configuration

パラメータ

exePath

実行可能ファイル関連付けられている構成ファイルへのパス

戻り値
Configuration オブジェクト

例外例外
例外種類条件

ConfigurationErrorsException

構成ファイル読み込むことができませんでした

解説解説

クライアント アプリケーションでは、すべてのユーザー適用するグローバル構成個々ユーザー適用する個別構成、およびローミング ユーザー適用する構成使用しますuserLevel 値は、構成ファイルユーザー レベルではない (構成ファイルアプリケーションと同じディレクトリにある)、またはユーザー単位レベル (構成ファイルユーザー レベル種類で決まるアプリケーション設定パスにある) のどちらであるかを示すことによって、開く構成ファイルの場所を決定します

userLevel パラメータ次の値のいずれかを渡すことによって、取得する構成指定します

使用例使用例

OpenExeConfiguration メソッド使用してカスタム構成セクション変更する方法次のコード例示します

' Modify a custom section.
' Show how to use the
' OpenExeConfiguration(ConfigurationUserLevel, 
' config file path) method.
Shared Sub ModifyCustomSection2()
   ' Get the application configuration file.
     Dim config As System.Configuration.Configuration
 = _
     ConfigurationManager.OpenExeConfiguration( _
     ConfigurationUserLevel.None)
   
     Dim custSection As CustomSection = _
     config.Sections(customSectionName)
   
   custSection.FileName = "anotherName.txt"
   custSection.MaxIdleTime = New TimeSpan(0, 20, 0)
   custSection.MaxUsers = custSection.MaxUsers + 20
   
   If Not custSection.ElementInformation.IsLocked
 Then
      config.Save()
   Else
      Console.WriteLine("Section was locked, could not update.")
   End If
End Sub 'ModifyCustomSection2
// Modify a custom section.
// Show how to use the
// OpenExeConfiguration(ConfigurationUserLevel, 
// config file path) method.
static void ModifyCustomSection2()
{
    // Get the application configuration file.
    System.Configuration.Configuration config =
         ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

    CustomSection custSection =
       config.Sections[customSectionName] as CustomSection;

    custSection.FileName = "anotherName.txt";
    custSection.MaxIdleTime = new TimeSpan(0, 20, 0);
    custSection.MaxUsers = custSection.MaxUsers + 20;

    if (!custSection.ElementInformation.IsLocked)
        config.Save();
    else
        Console.WriteLine("Section was locked, could not update.");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ConfigurationManager.OpenExeConfiguration メソッド




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ConfigurationManager.OpenExeConfiguration」の関連用語

ConfigurationManager.OpenExeConfigurationのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ConfigurationManager.OpenExeConfigurationのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS