This project is read-only.

Introduction to Settings4Net

Installation

  1. Download the latest Settings4Net library as a binary (Settings4Net.dll) or a class source code (Settings4Net.cs)
  2. Insert Settings4Net to your solution.
    • Copy Settings4Net.dll file to your application’s output directory (or alternatively set appropriate paths).
    • Add a Reference to Settings4Net.dll file.
  3. Settings4Net uses RamGecTools namespace (since it is part of RamGecTools suite (http://geciauskas.com/).

Basic Usage

  • Creating a new Settings4Net object:
// create your settings object
RamGecTools.Settings4Net MySettings = new RamGecTools.Settings4Net(); 
  • Add your settings:
MySettings["My String"] = "I'm using Settings4Net!";
MySettings["My Favorite Color"] = Color.FromArgb(128, 64, 198);
  • Retrieve your settings:
string str = MySettings["My String"].ToString();

// or use advanced functions:
Color color = (Color)MySettings.GetItemOrDefaultValue("My Favorite Color", Color.Thistle);

// will return a Color.Red, since "Item Doesn't Exist!" setting value wasn't created yet
Color color2 = (Color)MySettings.GetItemOrDefaultValue("Item Doesn't exist!", Color.Red);
  • Assign to PropertyGrid:
yourPropertyGrid.SelectedObject = MySettings.GeneratePropertyGridObject();
settings4net_ss.png
  • File Operations
// open
MySettings.Open("settings.xml"); // loads settings.xml file
MySettings.Open("settings.xml", true); // loads a file and checks if it was modified manually (returns false if so)
MySettings.Open("settings.xml", false, true); // last value indicates that Settings should be appended instead of overwritten (allowing you to combine settings from numerous files)

// save
MySettings.TrackModificationTimes = true; // set to true if you want to track date/time of last modification (default: false)
MySettings.Save("settings.xml"); // save to settings.xml

Advanced Functionality

Refer to Settings4Net Members documentation for more details.

Need Help? Support? Or you just need to leave some feedback.

Feel free to contact me.

Ramunas Geciauskas

Last edited Aug 1, 2011 at 11:35 PM by qisur, version 8

Comments

tommix May 27, 2013 at 2:03 PM 
Your example is bad, you forgot to add Settings it should be like this: "MySettings.Settings["My String"]" not just MySettings["My String"] :)

tommix May 26, 2013 at 9:26 PM 
Beje, gal yra bet kadangi negaliu ismeginti - ar yra galimybe setinga vadinti vienaip - pvz AllowDelete bet end useriui propertyGrid'e rodyti mano norima teksta pvz: "Leisti failo trinima" vietoj to, kad rodytu AllowDelete.

Tai gan naudinga programose keliom kalbom.

tommix May 26, 2013 at 9:22 PM 
Sveikas, dekui uz gera dalyka, bet zinok kazko neveikia. Kaip ir helpas - atidarus faila ten raso, kad reikia adresa nurodyti.

Kas liecia klaida su paciu lib'u tai gaunu: "Error 2 Cannot apply indexing with [] to an expression of type 'RamGecTools.Settings4Net'"

Klaida butent cia: MySettings["My String"] tipo nepriema jis jokiu ten ["My string"].

Naudoju tiesiog tavo pvz. ir klases source isitraukiau i using'us o ne dll'a