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

CFG file object. More...

Public Member Functions

 CfgFile (string FileName)
 Create an instance of the CfgFile object from the given CFG file. The instance is read/write, with AutoSave set to true. More...
 
 CfgFile (string FileName, bool AutoSave)
 Create an instance of the CfgFile object from the given CFG file. The instance is read/write, using the specified AutoSave value. More...
 
 CfgFile (string FileName, bool AutoSave, bool ReadOnly)
 Create an instance of the CfgFile object from the given CFG 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 CFG file.
 
bool SaveTo (string FileName, Encoding FileEncoding)
 Save the content to another CFG file.
 
bool Save ()
 Save the file. Return false in case of error.
 
void SaveEx ()
 Save the file. Throw an exception in case of error.
 
string ReadString (string Name, string Default="")
 Read a string entry from the CFG file.
 
int ReadInteger (string Name, int Default=0)
 Read an integer entry from the CFG file.
 
bool ReadBoolean (string Name, bool Default=false)
 Read a boolean entry from the CFG file.
 
bool Erase (string Name)
 Remove an entry from the CFG file. More...
 
bool Remove (string Name)
 Remove an entry from the INI file.
 
bool WriteName (string Name)
 Write an empty entry into the CFG file.
 
bool WriteString (string Name, string Value)
 Write a string entry into the CFG file.
 
bool WriteInteger (string Name, int Value)
 Write an integer entry into the CFG file.
 
bool WriteBoolean (string Name, bool value)
 Write a boolean entry into the CFG file.
 
string [] Read (bool withAssociatedValues)
 Return all the entries from the file. More...
 

Static Public Member Functions

static CfgFile OpenReadOnly (string FileName)
 Create an instance of the CfgFile object for the given CFG file. The instance is read only.
 
static CfgFile OpenReadOnly (string FileName, Encoding FileEncoding)
 Create an instance of the CfgFile object for the given CFG file. The instance is read only.
 
static CfgFile OpenReadWrite (string FileName, bool AutoSave=false)
 Create an instance of the CfgFile object for the given CFG file. The instance is read/write. More...
 
static CfgFile OpenReadWrite (string FileName, Encoding FileEncoding, bool AutoSave=false)
 Create an instance of the CfgFile object for the given CFG file. The instance is read/write. More...
 
static CfgFile CreateFromText (string Text)
 Create an instance of the CfgFile object from a content already loaded in memory.
 
static CfgFile CreateFromLines (string[] Lines)
 Create an instance of the CfgFile 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.
 

Detailed Description

CFG file object.

Constructor & Destructor Documentation

◆ CfgFile() [1/3]

SpringCard.LibCs.CfgFile.CfgFile ( string  FileName)

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

◆ CfgFile() [2/3]

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

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

◆ CfgFile() [3/3]

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

Create an instance of the CfgFile object from the given CFG file. The type of the instance depends on the parameters.

Member Function Documentation

◆ Erase()

bool SpringCard.LibCs.CfgFile.Erase ( string  Name)

Remove an entry from the CFG file.

◆ OpenReadWrite() [1/2]

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

Create an instance of the CfgFile object for the given CFG 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 CfgFile SpringCard.LibCs.CfgFile.OpenReadWrite ( string  FileName,
Encoding  FileEncoding,
bool  AutoSave = false 
)
static

Create an instance of the CfgFile object for the given CFG 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.

◆ Read()

string [] SpringCard.LibCs.CfgFile.Read ( bool  withAssociatedValues)

Return all the entries from the file.

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: