Giriş
Settings bilgisi proje içinde App.config dosyasında saklanır. Bu dosyayı elle değiştirebileceğimiz gibi GUI kullanarak ta değiştirebiliriz. GUI kullanmak için şöyle yaparız.
"Right click your project >> Navigate to Properties >> Settings"
App.config
applicationSettings değiştirilemez. Açıklaması şöyle
Settings sınıfına şöyle erişiriz.
Şöyle yaparız.
StringCollection tipi için şöyle yaparız.
Şöyle yaparız. Bilgiler <AssemblyName>.exe.config dosyasında saklanır.
Settings bilgisi proje içinde App.config dosyasında saklanır. Bu dosyayı elle değiştirebileceğimiz gibi GUI kullanarak ta değiştirebiliriz. GUI kullanmak için şöyle yaparız.
"Right click your project >> Navigate to Properties >> Settings"
App.config
İskeleti şöyledir.
<configuration>
<userSettings>
<DemoApp.Properties.Settings>
...
</DemoApp.Properties.Settings>
</userSettings>
<applicationSettings>
<DemoApp.Properties.Settings>
...
</DemoApp.Properties.Settings>
</applicationSettings>
</configuration>
ConstructorApplication-scope settings are read only, and can only be changed at design time or by altering the .exe.config file in between application sessions. User-scope settings, however, can be written at run time, just as you would change any property value. The new value persists for the duration of the application session. You can persist changes to user settings between application sessions by calling the Settings.Save method.
Settings sınıfına şöyle erişiriz.
Properties.Settings.Default;
Okumak İçin Alana Erişmek Şöyle yaparız.
var empNameVal = Properties.Settings.Default.EmployeeName;
Yazmak İçin Alana ErişmekStringCollection tipi için şöyle yaparız.
Properties.Settings.Default[1] = cboEmpName.Text;
int tipi için şöyle yaparız.Properties.Settings.Default.MessageNum++;
Save metoduŞöyle yaparız. Bilgiler <AssemblyName>.exe.config dosyasında saklanır.
Properties.Settings.Default.Save();
Hiç yorum yok:
Yorum Gönder