IniFileModifyKey
Modifies or adds a key to the currently loaded configuration file.
- If the key exists then its value is modified to the new keyValue and the keyComment is updated if it is not blank.
- If the key does not exist then it is added to the section with the specified value and comment.
- The INI file is saved after the modification to the hard drive directory.
Parameters:
sectionName
The name of the section where the key exists or will be added.
keyName:
The key identifier.
keyValue
The value associated with the key.
keyComment
The comment to precede the key in the INI file.
Return Value:
True on Success. If the function fails use GetErrorMessage to get the specific errors associated with the failure.
Interface Signature:
bool IniFileModifyKey(string sectionName, string keyName, string keyValue, string keyComment);
An example of how this function could be used is shown below.
using System;
namespace Example
{
/// <summary>
/// An simple example of how to utilize the API and get a reference to it
/// </summary>
public class ExampleClass
{
/// <summary>
/// Change a calibration's directory to use
/// </summary>
public static void ModifyDirectoryToUse(string calName, string newDirectory)
{
// Get a reference to the API interface
AteSystems.InCal.IApi api = AteSystems.InCal.API.Initialize(@"C:\Temp\MyConfig.ini", catchExceptions:true);
// Call the API function
api.IniFileModifyKey(calName, "DirectoryToUse", @"C:\MyData", "This is a new directory to be used");
}
}
}