AppSettingsSection.File Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Ek ayarlar sağlayan veya öğesinde appSettings
belirtilen ayarları geçersiz kılan bir yapılandırma dosyası alır veya ayarlar.
public:
property System::String ^ File { System::String ^ get(); void set(System::String ^ value); };
[System.Configuration.ConfigurationProperty("file", DefaultValue="")]
public string File { get; set; }
public string File { get; set; }
[<System.Configuration.ConfigurationProperty("file", DefaultValue="")>]
member this.File : string with get, set
member this.File : string with get, set
Public Property File As String
Özellik Değeri
Ek ayarlar sağlayan veya öğesinde appSettings
belirtilen ayarları geçersiz kılan bir yapılandırma dosyası.
- Öznitelikler
Örnekler
Aşağıdaki örnek, ek appSettings
değerleri bir dış yapılandırma dosyasında depolar ve bu dosyanın adını özelliğine File kaydeder.
// This function shows how to use the File property of the
// appSettings section.
// The File property is used to specify an auxiliary
// configuration file.
// Usually you create an auxiliary file off-line to store
// additional settings that you can modify as needed without
// causing an application restart,as in the case of a Web
// application.
// These settings are then added to the ones defined in the
// application configuration file.
static void IntializeConfigurationFile()
{
// Create a set of unique key/value pairs to store in
// the appSettings section of an auxiliary configuration
// file.
string time1 = String.Concat(DateTime.Now.ToLongDateString(),
" ", DateTime.Now.ToLongTimeString());
string time2 = String.Concat(DateTime.Now.ToLongDateString(),
" ", new DateTime(2009, 06, 30).ToLongTimeString());
string[] buffer = {"<appSettings>",
"<add key='AuxAppStg0' value='" + time1 + "'/>",
"<add key='AuxAppStg1' value='" + time2 + "'/>",
"</appSettings>"};
// Create an auxiliary configuration file and store the
// appSettings defined before.
// Note creating a file at run-time is just for demo
// purposes to run this example.
File.WriteAllLines("auxiliaryFile.config", buffer);
// Get the current configuration associated
// with the application.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Associate the auxiliary with the default
// configuration file.
System.Configuration.AppSettingsSection appSettings = config.AppSettings;
appSettings.File = "auxiliaryFile.config";
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload in memory of the
// changed section.
ConfigurationManager.RefreshSection("appSettings");
}
' This function shows how to use the File property of the
' appSettings section.
' The File property is used to specify an auxiliary
' configuration file.
' Usually you create an auxiliary file off-line to store
' additional settings that you can modify as needed without
' causing an application restart,as in the case of a Web
' application.
' These settings are then added to the ones defined in the
' application configuration file.
Private Shared Sub IntializeConfigurationFile()
' Create a set of unique key/value pairs to store in
' the appSettings section of an auxiliary configuration
' file.
Dim time1 As String = String.Concat(Date.Now.ToLongDateString(), " ", Date.Now.ToLongTimeString())
Dim time2 As String = String.Concat(Date.Now.ToLongDateString(), " ", New Date(2009, 6, 30).ToLongTimeString())
Dim buffer() As String = {"<appSettings>", "<add key='AuxAppStg0' value='" & time1 & "'/>", "<add key='AuxAppStg1' value='" & time2 & "'/>", "</appSettings>"}
' Create an auxiliary configuration file and store the
' appSettings defined before.
' Note creating a file at run-time is just for demo
' purposes to run this example.
File.WriteAllLines("auxiliaryFile.config", buffer)
' Get the current configuration associated
' with the application.
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
' Associate the auxiliary with the default
' configuration file.
Dim appSettings As System.Configuration.AppSettingsSection = config.AppSettings
appSettings.File = "auxiliaryFile.config"
' Save the configuration file.
config.Save(ConfigurationSaveMode.Modified)
' Force a reload in memory of the
' changed section.
ConfigurationManager.RefreshSection("appSettings")
End Sub
' This function shows how to use the File property of the
' appSettings section.
' The File property is used to specify an auxiliary
' configuration file.
' Usually you create an auxiliary file off-line to store
' additional settings that you can modify as needed without
' causing an application restart,as in the case of a Web
' application.
' These settings are then added to the ones defined in the
' application configuration file.
Private Shared Sub IntializeConfigurationFile()
' Create a set of unique key/value pairs to store in
' the appSettings section of an auxiliary configuration
' file.
Dim time1 As String = String.Concat(Date.Now.ToLongDateString(), " ", Date.Now.ToLongTimeString())
Dim time2 As String = String.Concat(Date.Now.ToLongDateString(), " ", New Date(2009, 6, 30).ToLongTimeString())
Dim buffer() As String = {"<appSettings>", "<add key='AuxAppStg0' value='" & time1 & "'/>", "<add key='AuxAppStg1' value='" & time2 & "'/>", "</appSettings>"}
' Create an auxiliary configuration file and store the
' appSettings defined before.
' Note creating a file at run-time is just for demo
' purposes to run this example.
File.WriteAllLines("auxiliaryFile.config", buffer)
' Get the current configuration associated
' with the application.
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
' Associate the auxiliary with the default
' configuration file.
Dim appSettings As System.Configuration.AppSettingsSection = config.AppSettings
appSettings.File = "auxiliaryFile.config"
' Save the configuration file.
config.Save(ConfigurationSaveMode.Modified)
' Force a reload in memory of the
' changed section.
ConfigurationManager.RefreshSection("appSettings")
End Sub
Şunlara uygulanır
Ayrıca bkz.
GitHub'da bizimle işbirliği yapın
Bu içeriğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Daha fazla bilgi için katkıda bulunan kılavuzumuzu inceleyin.