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


C# IniFile.Add方法代码示例

本文整理汇总了C#中IniFile.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.Add方法的具体用法?C# IniFile.Add怎么用?C# IniFile.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IniFile的用法示例。


在下文中一共展示了IniFile.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: saveConfigFile

        private void saveConfigFile()
        {
            string currentPath = Directory.GetCurrentDirectory();
            IniFile ini = new IniFile(currentPath + "\\config.ini");

            foreach (ListViewItem lsti in HostListView.Items)
            {
                IniSection section = new IniSection();
                section.Add("HostName", lsti.SubItems[0].Text);
                section.Add("Port", lsti.SubItems[1].Text);
                section.Add("Community", lsti.SubItems[2].Text);
                section.Add("Version", lsti.SubItems[3].Text);
                section.Add("User", lsti.SubItems[4].Text);
                section.Add("Password", lsti.SubItems[5].Text);
                ini.Add(lsti.SubItems[0].Text, section);
            }
            ini.Save();
        }
开发者ID:arnaudcoquelet,项目名称:Genesys_DashBoard,代码行数:18,代码来源:HddSnmpMonitorGuiMain.cs

示例2: Init

        public static bool Init()
        {
            string applicationFolder = Path.GetDirectoryName(Application.ExecutablePath);

            Filename = "KHR-1HV.ini";
            main_ini = new IniFile(string.Format("{0}\\{1}", applicationFolder, Filename));
            Log.Module = Module;
            if (main_ini.Exists())
            {
                Log.WriteLineSucces(string.Format("Opening: {0}", Filename));
                if (main_ini.Load())
                {
                    Log.WriteLineSucces(string.Format("Loading: {0}", Filename));
                    Read();
                    return true;
                }
                Log.WriteLineFail(string.Format("Loading: {0}", Filename));
                return false;
            }
            else
            {
                Log.WriteLineFail(string.Format("Opening: {0}", Filename));
                IniSection section = new IniSection();
                section.Add("Roboard", "RB100");
                section.Add("MotionReplay", "false");
                section.Add("EnableRemoteControl", "false");
                section.Add("PowerUpMotion", "-1");
                section.Add("LowPowerMotion", "-1");
                section.Add("LowPowerVoltage", "120");
                section.Add("Timebase", "100");
                section.Add("FPS", "1");
                section.Add("PA1REF", "0");
                section.Add("PA2REF", "0");
                section.Add("PA3REF", "0");
                section.Add("PA4REF", "0");
                section.Add("PA5REF", "0");
                section.Add("PA6REF", "0");
                for (int i = 0; i < StaticUtilities.numberOfServos; i++)
                {
                    string tmp = string.Format("CH{0}", (i + 1));
                    section.Add(tmp, "1");
                }
                main_ini.Add("Main", section);
                Log.WriteLineSucces(string.Format("Creating: {0}", Filename));
                if (Save())
                {
                    Read();
                    return true;
                }
                return false;
            }
        }
开发者ID:tejastank,项目名称:KHR-1HV-Server,代码行数:52,代码来源:MainIni.cs

示例3: mainServer_messageHandler


//.........这里部分代码省略.........
                            Msg[5] = khr_1hv_motion[strItems]["Color"];
                            Msg[6] = khr_1hv_motion[strItems]["Type"];
                            Msg[7] = khr_1hv_motion[strItems]["Prm"];
                            sendMsg = string.Join(",", Msg);
                            break;
                        case "Link":
                            Msg = new string[4];
                            string strLinks = string.Format("Link{0}", Links++);
                            Msg[0] = khr_1hv_motion[strLinks]["Main"];
                            Msg[1] = khr_1hv_motion[strLinks]["Origin"];
                            Msg[2] = khr_1hv_motion[strLinks]["Final"];
                            Msg[3] = khr_1hv_motion[strLinks]["Point"];
                            sendMsg = string.Join(",", Msg);
                            break;
                        default:
                            break;
                    }
                    break;
                case "WriteMotionFile":
                    switch (message[1])
                    {
                        case "Open":
                            // create random filename.
                            fileName = Path.ChangeExtension(Path.GetRandomFileName(), "RMF");
                            fileName = string.Format("{0}\\{1}", motionsFolder, fileName);
                            // get the index for the datatable where the
                            // motion is going to be writen.
                            selectedMotionIndex = Convert.ToInt32(message[2]) + 1;
                            khr_1hv_motion = new IniFile(fileName);
                            sendMsg = "Ok";
                            break;
                        case "GraphicalEdit":
                            IniSection section1 = new IniSection();
                            section1.Add("Type", message[2]);
                            section1.Add("Width", message[3]);
                            section1.Add("Height", message[4]);
                            section1.Add("Items", message[5]);
                            section1.Add("Links", message[6]);
                            section1.Add("Start", message[7]);
                            section1.Add("Name", message[8]);
                            section1.Add("Ctrl", message[9]);
                            khr_1hv_motion.Add("GraphicalEdit", section1);
                            Items = 0;
                            Links = 0;
                            sendMsg = "Ok";
                            break;
                        case "Item":
                            IniSection section2 = new IniSection();
                            section2.Add("Name", message[2]);
                            section2.Add("Width", message[3]);
                            section2.Add("Height", message[4]);
                            section2.Add("Left", message[5]);
                            section2.Add("Top", message[6]);
                            section2.Add("Color", message[7]);
                            section2.Add("Type", message[8]);
                            string strChannel = string.Format("{0}", message[9]);
                            for (int i = 10; i < message.Length; i++)
                            {
                                strChannel = string.Format("{0},{1}", strChannel, message[i]);
                            }
                            section2.Add("Prm", strChannel);
                            string strItems = string.Format("Item{0}", Items++);
                            khr_1hv_motion.Add(strItems, section2);
                            sendMsg = "Ok";
                            break;
                        case "Link":
开发者ID:tejastank,项目名称:KHR-1HV-Server,代码行数:67,代码来源:Program.cs

示例4: Read

        // Methods
        //
        public static bool Read()
        {
            // Read a motion from the server
            Roboard.NetworkClient.messageHandler += new NetworkClient.NewMessageEventHandler(WriteNetworkClient_messageHandler);
            string strCommand = string.Format("ReadMotionFile");

            // 1 - send the selectedmotion index to the server
            //
            sendString = string.Format("{0},Open,{1}", strCommand, _selectedMotionIndex);
            if (!handleNetworkMessage(sendString))
                return false;
            // 2 - if exists than create a new motionData.
            //
            tempMotionData = new IniFile(string.Empty);
            //========================================
            // 3 - Read the GraphicalEdit part section
            //========================================

            // send to the server
            sendString = string.Format("{0},{1}", strCommand, StaticUtilities.SectionGraphicalEdit);
            if (!handleNetworkMessage(sendString))
                return false;

            IniSection graphicalEditSection = new IniSection();
            for (int i = 0; i < StaticUtilities.GraphicalEdit.Length; i++)
                graphicalEditSection.Add(StaticUtilities.GraphicalEdit[i], strMessage[i]);
            tempMotionData.Add(StaticUtilities.SectionGraphicalEdit, graphicalEditSection);

            //===========================
            // 4 - Read the items section
            //===========================
            int Items = Convert.ToInt32(tempMotionData[StaticUtilities.SectionGraphicalEdit][StaticUtilities.GraphicalEditItems]);
            for (int i = 0; i < Items; i++)
            {
                // send to the server
                sendString = string.Format("{0},{1}", strCommand, StaticUtilities.SectionItem);
                if (!handleNetworkMessage(sendString))
                    return false;

                IniSection itemSection = new IniSection();
                for (int j = 0; j < StaticUtilities.Item.Length - 1; j++) // minus one because Prm
                    itemSection.Add(StaticUtilities.Item[j], strMessage[j]);
                string strChannel = string.Format("{0}", strMessage[StaticUtilities.Item.Length - 1]);
                for (int k = StaticUtilities.Item.Length; k < strMessage.Length; k++)
                    strChannel = string.Format("{0},{1}", strChannel, strMessage[k]);
                itemSection.Add(StaticUtilities.ItemPrm, strChannel);
                tempMotionData.Add(string.Format("{0}{1}", StaticUtilities.SectionItem, i), itemSection);
            }
            //===========================
            // 5 - Read the links section
            //===========================
            int Links = Convert.ToInt32(tempMotionData[StaticUtilities.SectionGraphicalEdit][StaticUtilities.GraphicalEditLinks]);
            for (int i = 0; i < Links; i++)
            {
                // send to the server
                sendString = string.Format("{0},{1}", strCommand, StaticUtilities.SectionLink);
                if (!handleNetworkMessage(sendString))
                    return false;

                IniSection linkSection = new IniSection();
                for (int j = 0; j < StaticUtilities.Link.Length - 1; j++) // minus one because Point
                    linkSection.Add(StaticUtilities.Link[j], strMessage[j]);

                string strPoint = string.Format("{0}", strMessage[StaticUtilities.Link.Length - 1]);
                for (int k = StaticUtilities.Link.Length; k < strMessage.Length; k++)
                    strPoint = string.Format("{0},{1}", strPoint, strMessage[k]);
                linkSection.Add(StaticUtilities.LinkPoint, strPoint);
                tempMotionData.Add(string.Format("{0}{1}", StaticUtilities.SectionLink, i), linkSection);
            }
            // 6 - close and other things to be done.
            motionData = tempMotionData;
            Close();
            return true;
        }
开发者ID:Subwolf666,项目名称:Roboard-Client,代码行数:76,代码来源:ToolMenu.cs

示例5: saveSnmpConfigFile

        private void saveSnmpConfigFile()
        {
            IniFile ini = new IniFile("SNMP Config.ini");

            foreach (ListViewItem lsti in SnmpHostListView.Items)
            {
                IniSection section = new IniSection();
                section.Add("HostName", lsti.SubItems[0].Text);
                section.Add("Port", lsti.SubItems[1].Text);
                section.Add("Community", lsti.SubItems[2].Text);
                section.Add("Version", lsti.SubItems[3].Text);
                section.Add("User", lsti.SubItems[4].Text);
                section.Add("Password", lsti.SubItems[5].Text);
                ini.Add(lsti.SubItems[0].Text, section);
            }
            ini.Save();
        }
开发者ID:arnaudcoquelet,项目名称:Genesys_DashBoard,代码行数:17,代码来源:Dashboard.cs

示例6: saveInfoMartConfigFile

        private void saveInfoMartConfigFile()
        {
            IniFile ini = new IniFile("InfoMart Config.ini");

            if (InfoMartJobConfig != null)
            {
                IniSection section = new IniSection();
                section.Add("HostName", InfoMartJobConfig.hostname);
                section.Add("Port", InfoMartJobConfig.port );
                section.Add("Service", InfoMartJobConfig.service );
                section.Add("Table", InfoMartJobConfig.table );
                section.Add("Username", InfoMartJobConfig.username );
                section.Add("Password", InfoMartJobConfig.password );
                ini.Add("InfoMart DB", section);
            }
            ini.Save();
        }
开发者ID:arnaudcoquelet,项目名称:Genesys_DashBoard,代码行数:17,代码来源:Dashboard.cs


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