本文整理汇总了C#中IniFile.EraseSection方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.EraseSection方法的具体用法?C# IniFile.EraseSection怎么用?C# IniFile.EraseSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IniFile
的用法示例。
在下文中一共展示了IniFile.EraseSection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdSave_Click
void cmdSave_Click(object sender, EventArgs e)
{
if (!Dialog.ValidateIsNotEmpty(txtHostname)) return;
if (!Dialog.ValidateIsNotEmpty(txtPassword)) return;
if (txtHostname.Text.Trim().ToUpper() != _OriginalHostname) {
using (IniFile Ini = new IniFile(Config.Default.FileName))
{
Ini.EraseSection(_OriginalHostname);
Ini.Save();
}
}
HostConfig HC = new HostConfig(txtHostname.Text.Trim());
HC.LastUpdateDate = DateTime.MinValue;
HC.Password = txtPassword.SecureText.GetSecureText();
HC.Provider = ProviderName.DtDNS;
HC.Username = HC.Hostname;
if (HC.Disabled)
{
// Saving changes should reset the disabled state and last update date, so a new update can be attempted right away
HC.Disabled = false;
}
HC.Save();
DialogResult = DialogResult.OK;
}
示例2: HandleLogOffOrOnProcessDotIni
private void HandleLogOffOrOnProcessDotIni(RMSQLiteConnection DB, string offOrOn, string inOrOut)
{
AddToLog("Importing settings for log" + offOrOn + "process.ini");
using (IniFile Ini = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "config", "log" + offOrOn + "process.ini")))
{
// Erase old sections
string[] Sections = Ini.ReadSections();
foreach (string Section in Sections)
{
Ini.EraseSection(Section);
}
SQL = "SELECT * FROM Log" + inOrOut + "ProcessTbl ORDER BY StepNumber";
DB.ExecuteReader(SQL);
while (DB.Reader.Read())
{
string Name = "Log" + offOrOn + "Process" + DB.Reader["StepNumber"].ToString();
string Action = CommandToAction(DB.Reader["Command"].ToString());
string Parameters = DB.Reader["Parameters"].ToString();
string RequiredAccess = DB.Reader["RequiredAccess"].ToString();
if (Action == DB.Reader["Command"].ToString())
{
AddToLog(" - Ignoring command that no longer exists (" + Action + ")");
}
else
{
// See if we need to add the logon/off process as a door
if (Action == "RunDoor")
{
string[] CommandAndParameters = DB.Reader["Parameters"].ToString().Split(' ');
string Command = CommandAndParameters[0];
string DoorParameters = string.Join(" ", CommandAndParameters, 1, CommandAndParameters.Length - 1);
bool Native = DB.Reader["Command"].ToString() == "EXEC";
using (IniFile DoorIni = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "doors", GetSafeDoorFileName(Name) + ".ini")))
{
DoorIni.WriteString("DOOR", "Name", Name);
DoorIni.WriteString("DOOR", "Command", Command);
DoorIni.WriteString("DOOR", "Parameters", DoorParameters);
DoorIni.WriteString("DOOR", "Native", Native.ToString());
DoorIni.WriteString("DOOR", "ForceQuitDelay", "5");
DoorIni.WriteString("DOOR", "WindowStyle", "Minimized");
}
AddToLog(" - Added Door = " + Name);
AddToLog(" Command = " + Command);
AddToLog(" Parameters = " + DoorParameters);
AddToLog(" Native = " + Native.ToString());
// Override settings to be used below
Action = "RunDoor";
Parameters = Name;
}
Ini.WriteString(Name, "Name", Name);
Ini.WriteString(Name, "Action", Action);
Ini.WriteString(Name, "Parameters", Parameters);
Ini.WriteString(Name, "RequiredAccess", RequiredAccess);
AddToLog(" - Added Name = " + Name);
AddToLog(" Action = " + Action);
AddToLog(" Parameters = " + Parameters);
AddToLog(" RequiredAccess = " + RequiredAccess);
}
}
DB.Reader.Close();
}
AddToLog("");
}
示例3: Delete
/// <summary>
/// Advanced delete method that allows you to specify the section to delete
/// </summary>
/// <param name="sectionName">The section to delete within the INI</param>
protected void Delete(string sectionName)
{
// Store the section name
SectionName = sectionName;
// Load the application ini
using (IniFile Ini = new IniFile(FileName, IniPassword))
{
// Check if the desired section exists
if (Ini.SectionExists(sectionName))
{
// Yep, so delete it
Ini.EraseSection(sectionName);
Ini.Save();
}
}
}