SpringCard LibCs for .NET  18.10.10
A set of utilities to simplify the development of .NET application
SpringCard.LibCs.IniFile Class Reference

INI file object (pure .NET implementation, no dependency to Windows' libraries) More...

Public Member Functions

 IniFile (string FileName)
 Create an instance of the IniFile object from the given INI file. The instance is read/write, with AutoSave set to true. More...
 
 IniFile (string FileName, bool AutoSave)
 Create an instance of the IniFile object from the given INI file. The instance is read/write, using the specified AutoSave value. More...
 
 IniFile (string FileName, bool AutoSave, bool ReadOnly)
 Create an instance of the IniFile object from the given INI file. The type of the instance depends on the parameters. More...
 
bool Load ()
 (Re)load the content from the file
 
bool SaveTo (string FileName)
 Save the content to another INI file.
 
bool SaveTo (string FileName, Encoding FileEncoding)
 Save the content to another INI file.
 
bool Save ()
 Save the file. Return false in case of error.
 
void SaveEx ()
 Save the file. Throw an exception in case of error.
 
List< string > GetSections ()
 Get the list of sections in the INI file. More...
 
string ReadString (string Section, string Name, string Default="")
 Read a string entry from the INI file.
 
int ReadInteger (string Section, string Name, int Default=0)
 Read an integer entry from the INI file.
 
bool ReadBoolean (string Section, string Name, bool Default=false)
 Read a boolean entry from the INI file.
 
bool Erase (string Section, string Name)
 Remove an entry from the INI file. More...
 
bool Remove (string Section, string Name)
 Remove an entry from the INI file.
 
bool WriteName (string Section, string Name)
 Write an empty entry into the INI file.
 
bool WriteString (string Section, string Name, string Value)
 Write a string entry into the INI file.
 
bool WriteInteger (string Section, string Name, int Value)
 Write an integer entry into the INI file.
 
bool WriteBoolean (string Section, string Name, bool value)
 Write a boolean entry into the INI file.
 
string [] ReadSection (string Section, bool withAssociatedValues=false)
 Return all the entries from a given section. More...
 

Static Public Member Functions

static IniFile OpenReadOnly (string FileName)
 Create an instance of the IniFile object for the given INI file. The instance is read only.
 
static IniFile OpenReadOnly (string FileName, Encoding FileEncoding)
 Create an instance of the IniFile object for the given INI file. The instance is read only.
 
static IniFile OpenReadWrite (string FileName, bool AutoSave=false)
 Create an instance of the IniFile object for the given INI file. The instance is read/write. More...
 
static IniFile OpenReadWrite (string FileName, Encoding FileEncoding, bool AutoSave=false)
 Create an instance of the IniFile object for the given INI file. The instance is read/write. More...
 
static IniFile CreateFromText (string Text)
 Create an instance of the IniFile object from a content already loaded in memory.
 
static IniFile CreateFromLines (string[] Lines)
 Create an instance of the IniFile object from a content already loaded in memory.
 

Static Public Attributes

static Encoding DefaultEncoding = Encoding.UTF8
 Default text encoding, when not specified explicitely in the constructor. Default is UTF8.
 

Properties

List< string > Sections [get]
 The list of sections in the INI file.
 

Detailed Description

INI file object (pure .NET implementation, no dependency to Windows' libraries)

Constructor & Destructor Documentation

◆ IniFile() [1/3]

SpringCard.LibCs.IniFile.IniFile ( string  FileName)

Create an instance of the IniFile object from the given INI file. The instance is read/write, with AutoSave set to true.

◆ IniFile() [2/3]

SpringCard.LibCs.IniFile.IniFile ( string  FileName,
bool  AutoSave 
)

Create an instance of the IniFile object from the given INI file. The instance is read/write, using the specified AutoSave value.

◆ IniFile() [3/3]

SpringCard.LibCs.IniFile.IniFile ( string  FileName,
bool  AutoSave,
bool  ReadOnly 
)

Create an instance of the IniFile object from the given INI file. The type of the instance depends on the parameters.

Member Function Documentation

◆ Erase()

bool SpringCard.LibCs.IniFile.Erase ( string  Section,
string  Name 
)

Remove an entry from the INI file.

◆ GetSections()

List<string> SpringCard.LibCs.IniFile.GetSections ( )

Get the list of sections in the INI file.

◆ OpenReadWrite() [1/2]

static IniFile SpringCard.LibCs.IniFile.OpenReadWrite ( string  FileName,
bool  AutoSave = false 
)
static

Create an instance of the IniFile object for the given INI file. The instance is read/write.

If the AutoSave parameter is set to false, Save() must be called explicitly, otherwise the write operations are lost.

◆ OpenReadWrite() [2/2]

static IniFile SpringCard.LibCs.IniFile.OpenReadWrite ( string  FileName,
Encoding  FileEncoding,
bool  AutoSave = false 
)
static

Create an instance of the IniFile object for the given INI file. The instance is read/write.

If the AutoSave parameter is set to false, Save() must be called explicitly, otherwise the write operations are lost.

◆ ReadSection()

string [] SpringCard.LibCs.IniFile.ReadSection ( string  Section,
bool  withAssociatedValues = false 
)

Return all the entries from a given section.

If withAssociatedValues is set to true, the entries are returned as name=value, otherwise, only the name is returned


The documentation for this class was generated from the following file: