Config Helper
SaveSetting Method
Example 



KellermanSoftware.ConfigHelper Namespace > IniReaderWriter Class : SaveSetting Method
The section name. Use GLOBAL for the global section.
The setting name
The value to set
The path to the INI file
Save a value to an INI file
No COM Interop is used
If the file does not exist it will be created. If the section does not exist it will be created. If the setting already exists it will be updated. If the setting does not exist, it will be added.
Syntax
Public Function SaveSetting( _
   ByVal sectionName As String, _
   ByVal settingName As String, _
   ByVal settingValue As String, _
   ByVal filePath As String _
) As Boolean
Dim instance As IniReaderWriter
Dim sectionName As String
Dim settingName As String
Dim settingValue As String
Dim filePath As String
Dim value As Boolean
 
value = instance.SaveSetting(sectionName, settingName, settingValue, filePath)
public bool SaveSetting( 
   string sectionName,
   string settingName,
   string settingValue,
   string filePath
)
public:
bool SaveSetting( 
   String^ sectionName,
   String^ settingName,
   String^ settingValue,
   String^ filePath
) 

Parameters

sectionName
The section name. Use GLOBAL for the global section.
settingName
The setting name
settingValue
The value to set
filePath
The path to the INI file

Return Value

True if it was saved successfully
Exceptions
ExceptionDescription
Occurs when sectionName, settingName or filePath is null
Example
//Trial Mode
IniReaderWriter iniReaderWriter = new IniReaderWriter();
 
//License Mode
//IniReaderWriter iniReaderWriter = new IniReaderWriter("place user name here", "place license key here");
 
iniReaderWriter.SaveSetting("MySection", "MySettingName", "MySettingValue", "MySettingsFile.ini");
 
string results = iniReaderWriter.GetSetting("MySection", "MySettingName", "MySettingsFile.ini");
Console.WriteLine(results);
'Trial Mode
Dim iniReaderWriter As New IniReaderWriter()
 
'License Mode
'Dim iniReaderWriter As New IniReaderWriter("place user name here", "place license key here")
 
iniReaderWriter.SaveSetting("MySection", "MySettingName", "MySettingValue", "MySettingsFile.ini")
 
Dim results As String = iniReaderWriter.GetSetting("MySection", "MySettingName", "MySettingsFile.ini")
Console.WriteLine(results)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IniReaderWriter Class
IniReaderWriter Members