本文整理匯總了C#中System.Web.Configuration.WebConfigurationManager.OpenMachineConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:C# WebConfigurationManager.OpenMachineConfiguration方法的具體用法?C# WebConfigurationManager.OpenMachineConfiguration怎麽用?C# WebConfigurationManager.OpenMachineConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Web.Configuration.WebConfigurationManager
的用法示例。
在下文中一共展示了WebConfigurationManager.OpenMachineConfiguration方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OpenMachineConfiguration1
// Show how to use OpenMachineConfiguration().
// It gets the machine.config file on the current
// machine and displays section information.
static void OpenMachineConfiguration1()
{
// Get the machine.config file on the current machine.
System.Configuration.Configuration config =
WebConfigurationManager.OpenMachineConfiguration();
// Loop to get the sections. Display basic information.
Console.WriteLine("Name, Allow Definition");
int i = 0;
foreach (ConfigurationSection section in config.Sections)
{
Console.WriteLine(
section.SectionInformation.Name + "\t" +
section.SectionInformation.AllowExeDefinition);
i += 1;
}
Console.WriteLine("[Total number of sections: {0}]", i);
// Display machine.config path.
Console.WriteLine("[File path: {0}]", config.FilePath);
}
開發者ID:.NET開發者,項目名稱:System.Web.Configuration,代碼行數:24,代碼來源:WebConfigurationManager.OpenMachineConfiguration
示例2: OpenMachineConfiguration2
// Show how to use OpenMachineConfiguration(string).
// It gets the machine.config file applicabe to the
// specified resource and displays section
// basic information.
static void OpenMachineConfiguration2()
{
// Get the machine.config file applicabe to the
// specified reosurce.
System.Configuration.Configuration config =
WebConfigurationManager.OpenMachineConfiguration("configTest");
// Loop to get the sections. Display basic information.
Console.WriteLine("Name, Allow Definition");
int i = 0;
foreach (ConfigurationSection section in config.Sections)
{
Console.WriteLine(
section.SectionInformation.Name + "\t" +
section.SectionInformation.AllowExeDefinition);
i += 1;
}
Console.WriteLine("[Total number of sections: {0}]", i);
// Display machine.config path.
Console.WriteLine("[File path: {0}]", config.FilePath);
}
開發者ID:.NET開發者,項目名稱:System.Web.Configuration,代碼行數:26,代碼來源:WebConfigurationManager.OpenMachineConfiguration
示例3: OpenMachineConfiguration3
// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server and
// applicabe to the specified reosurce and displays section
// basic information.
static void OpenMachineConfiguration3()
{
// Get the machine.config file applicabe to the
// specified reosurce and on the specified server.
System.Configuration.Configuration config =
WebConfigurationManager.OpenMachineConfiguration("configTest",
"myServer");
// Loop to get the sections. Display basic information.
Console.WriteLine("Name, Allow Definition");
int i = 0;
foreach (ConfigurationSection section in config.Sections)
{
Console.WriteLine(
section.SectionInformation.Name + "\t" +
section.SectionInformation.AllowExeDefinition);
i += 1;
}
Console.WriteLine("[Total number of sections: {0}]", i);
// Display machine.config path.
Console.WriteLine("[File path: {0}]", config.FilePath);
}
開發者ID:.NET開發者,項目名稱:System.Web.Configuration,代碼行數:27,代碼來源:WebConfigurationManager.OpenMachineConfiguration
示例4: OpenMachineConfiguration4
// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server,
// applicabe to the specified reosurce, for the specified user
// and displays section basic information.
static void OpenMachineConfiguration4()
{
// Get the current user token.
IntPtr userToken =
System.Security.Principal.WindowsIdentity.GetCurrent().Token;
// Get the machine.config file applicabe to the
// specified reosurce, on the specified server for the
// specified user.
System.Configuration.Configuration config =
WebConfigurationManager.OpenMachineConfiguration("configTest",
"myServer", userToken);
// Loop to get the sections. Display basic information.
Console.WriteLine("Name, Allow Definition");
int i = 0;
foreach (ConfigurationSection section in config.Sections)
{
Console.WriteLine(
section.SectionInformation.Name + "\t" +
section.SectionInformation.AllowExeDefinition);
i += 1;
}
Console.WriteLine("[Total number of sections: {0}]", i);
// Display machine.config path.
Console.WriteLine("[File path: {0}]", config.FilePath);
}
開發者ID:.NET開發者,項目名稱:System.Web.Configuration,代碼行數:32,代碼來源:WebConfigurationManager.OpenMachineConfiguration
示例5: OpenMachineConfiguration5
// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server,
// applicabe to the specified reosurce, for the specified user
// and displays section basic information.
static void OpenMachineConfiguration5()
{
// Set the user id and password.
string user =
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
// Substitute with actual password.
string password = "userPassword";
// Get the machine.config file applicabe to the
// specified reosurce, on the specified server for the
// specified user.
System.Configuration.Configuration config =
WebConfigurationManager.OpenMachineConfiguration("configTest",
"myServer", user, password);
// Loop to get the sections. Display basic information.
Console.WriteLine("Name, Allow Definition");
int i = 0;
foreach (ConfigurationSection section in config.Sections)
{
Console.WriteLine(
section.SectionInformation.Name + "\t" +
section.SectionInformation.AllowExeDefinition);
i += 1;
}
Console.WriteLine("[Total number of sections: {0}]", i);
// Display machine.config path.
Console.WriteLine("[File path: {0}]", config.FilePath);
}
開發者ID:.NET開發者,項目名稱:System.Web.Configuration,代碼行數:34,代碼來源:WebConfigurationManager.OpenMachineConfiguration