Table of Contents

Class IniFile

Namespace
Amazon.Runtime.Internal.Util
Assembly
AWSSDK.Core.dll

Provides read/write access to a file in the INI format.

This class is not threadsafe.

public class IniFile
Inheritance
IniFile
Derived
Inherited Members

Constructors

IniFile(string)

Construct a new IniFile.

public IniFile(string filePath)

Parameters

filePath string

path of the IniFile

Properties

FilePath

the path of the file

public string FilePath { get; }

Property Value

string

Methods

CopySection(string, string, Dictionary<string, string>)

Copy the section fromSectionName to toSectionName

public void CopySection(string fromSectionName, string toSectionName, Dictionary<string, string> replaceProperties)

Parameters

fromSectionName string
toSectionName string
replaceProperties Dictionary<string, string>

Any properties in the original section that are also in this dictionary will be replaced by the value from this dictionary.

CopySection(string, string, Dictionary<string, string>, bool)

Copy the section fromSectionName to toSectionName

public void CopySection(string fromSectionName, string toSectionName, Dictionary<string, string> replaceProperties, bool force)

Parameters

fromSectionName string
toSectionName string
replaceProperties Dictionary<string, string>

Any properties in the original section that are also in this dictionary will be replaced by the value from this dictionary.

force bool

if true and destination section already exists overwrite it

DeleteSection(string)

If the section exists, delete it from the INI file.

public void DeleteSection(string sectionName)

Parameters

sectionName string

section to delete

EditSection(string, SortedDictionary<string, string>)

Update the section with the properties given. If the section doesn't exist, it will be appended to the file.

Notes:

  1. Any properties that do exist in the section will be updated.
  2. A null value for a property denotes that it should be deleted from the section
  3. If any properties don't exist they will be appended to the end of the section in the same order they appear in the SortedDictionary.
public virtual void EditSection(string sectionName, SortedDictionary<string, string> properties)

Parameters

sectionName string

name of the section to operate on

properties SortedDictionary<string, string>

properties to add/update/delete

EnsureSectionExists(string)

Check if the section exists. If not, append it to the end of the file.

public void EnsureSectionExists(string sectionName)

Parameters

sectionName string

section to ensure exists

ListSectionNames()

public virtual HashSet<string> ListSectionNames()

Returns

HashSet<string>

Persist()

Persist the changes to this INI file to disk.

public void Persist()

RenameSection(string, string)

Rename the section fromSectionName to toSectionName

public void RenameSection(string oldSectionName, string newSectionName)

Parameters

oldSectionName string
newSectionName string

RenameSection(string, string, bool)

Rename the section fromSectionName to toSectionName

public void RenameSection(string oldSectionName, string newSectionName, bool force)

Parameters

oldSectionName string
newSectionName string
force bool

if true and destination section already exists overwrite it

SectionExists(string)

Determine if a section exists in the INI file.

public bool SectionExists(string sectionName)

Parameters

sectionName string

name of section to look for

Returns

bool

true if the section exists, false otherwise

SectionExists(Regex, out string)

Determine if a section exists in the INI file.

public bool SectionExists(Regex sectionNameRegex, out string sectionName)

Parameters

sectionNameRegex Regex

Regex to match name of section to look for

sectionName string

name of section if regex matches

Returns

bool

true if the section exists, false otherwise

ToString()

public override string ToString()

Returns

string

TryGetSection(string, out Dictionary<string, string>)

Return the properties for the section if it exists.

public virtual bool TryGetSection(string sectionName, out Dictionary<string, string> properties)

Parameters

sectionName string

name of section to get

properties Dictionary<string, string>

properties contained in the section

Returns

bool

True if the section was found, false otherwise

TryGetSection(Regex, out Dictionary<string, string>)

Return the properties for the section if it exists.

public bool TryGetSection(Regex sectionNameRegex, out Dictionary<string, string> properties)

Parameters

sectionNameRegex Regex

Regex to match name of section to get

properties Dictionary<string, string>

properties contained in the section

Returns

bool

True if the section was found, false otherwise

TryGetSection(Regex, out string, out Dictionary<string, string>)

Return the properties for the section if it exists.

public bool TryGetSection(Regex sectionNameRegex, out string sectionName, out Dictionary<string, string> properties)

Parameters

sectionNameRegex Regex

Regex to match name of section to get

sectionName string

name of section if regex matches

properties Dictionary<string, string>

properties contained in the section

Returns

bool

True if the section was found, false otherwise