当前位置: 首页>>代码示例>>C#>>正文


C# IniFile.EraseSection方法代码示例

本文整理汇总了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;
        }
开发者ID:rickparrish,项目名称:PDDNS,代码行数:27,代码来源:AddEditDtDNSForm.cs

示例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("");
        }
开发者ID:Robin--,项目名称:GameSrv,代码行数:70,代码来源:MainForm.cs

示例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();
                }
            }
        }
开发者ID:Robin--,项目名称:RMLib,代码行数:22,代码来源:ConfigHelper.cs


注:本文中的IniFile.EraseSection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。