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


C# IniFile.WriteValue方法代码示例

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


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

示例1: SaveToIniFile

        private void SaveToIniFile(string iniFilePath)
        {
            IniFile iniFile = new IniFile(iniFilePath);

            iniFile.WriteValue(strLogName, "EnableAutoDeleteLog", autoDeleteLogCheckBox.Checked == true ? 1 : 0);
            iniFile.WriteValue(strLogName, "AutoDeleteLogDays", (int)autoDeleteDaysNumeric.Value);
        }
开发者ID:damonlin,项目名称:Reporter,代码行数:7,代码来源:AlarmReportForm.cs

示例2: WriteUserSettings

 private void WriteUserSettings()
 {
     try
     {
         IniFile iniFile = new IniFile(FileNameUtils.GetUserIniFileName(InboundSettings.AppSettingsDir));
         iniFile.WriteValue(FORM_NAME, "Top", this.Top);
         iniFile.WriteValue(FORM_NAME, "Left", this.Left);
     }
     catch (Exception error)
     {
         XtraMessageBox.Show("An error occurred while saving the user settings file." + Environment.NewLine +
                "Error CNF-426 in " + FORM_NAME + ".WriteUserSettings(): " + error.Message,
              FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:15,代码来源:frmAssignFaxNo.cs

示例3: load

 public static void load()
 {
     string path = Application.StartupPath + "\\settings.ini";
     if (!File.Exists(path)) { File.Create(path); }
     //
     ini = new IniFile(path);
     //
     if (ini.GetInt32("Settings", "Update_3", 0) == 0)
     {
         Check_Interval = 60;
         ini.WriteValue("Settings", "Update_3", 1);
     }
 }
开发者ID:Wagnerp,项目名称:chromium-updater,代码行数:13,代码来源:Settings.cs

示例4: homeExePath_Click

        /// <summary>
        /// Opens a folder browser dialog to find the fsx.exe path
        /// The path is then stored in locations.ini
        /// </summary>
        private void homeExePath_Click(object sender, EventArgs e)
        {
            // Set the folder browser description
            homeBrowser.Description = homeBrowser.Description.Replace("[0]", "Flight Simulator X executable");

            using (IniFile iniFile = new IniFile())
            {
                // Switch: locations.ini
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                // Set the current selected path to the one in the ini
                homeBrowser.SelectedPath = iniFile.ReadValue("LOCATIONS", "exe");

                // Show the folder browser
                homeBrowser.ShowDialog();

                // Write the new value to the ini file
                iniFile.WriteValue("LOCATIONS", "exe", homeBrowser.SelectedPath.ToString());

                // Update the textbox
                homeExePath.Text = iniFile.ReadValue("LOCATIONS", "exe");
            }

            // Reset the folder browser description
            homeBrowser.Description = homeBrowser.Description.Replace("Flight Simulator X executable", "[0]");
        }
开发者ID:StevenFrost,项目名称:Editors,代码行数:30,代码来源:Main.cs

示例5: homeApplyButton_ButtonClick

        /// <summary>
        /// Applies the current selected resolution to fsx.cfg
        /// </summary>
        private void homeApplyButton_ButtonClick()
        {
            using (IniFile iniFile = new IniFile())
            {
                /// <switch>current profile</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";
                iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");

                // Ding var
                bool ding = false;

                // Check for the secret ding switch
                if (iniFile.ReadValue("MISCELLANEOUS", "ding") == "1")
                    ding = true;

                /// <switch>fsx.cfg</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                if (System.IO.File.Exists(iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg"))
                {
                    if (System.IO.File.Exists(iniFile.ReadValue("LOCATIONS", "exe") + @"\fsx.exe"))
                    {
                        iniFile.IniPath = iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg";

                        if (homeResolution.SelectedItem != null)
                        {
                            // Ding!
                            if (ding)
                                using (Sound.TmleSound sound = new Sound.TmleSound())
                                    sound.Play(Application.StartupPath + @"\Resources\apply.resource", sound.SND_FILENAME | sound.SND_ASYNC);

                            // Split the selected item up into a new array
                            string[] selectedItem = homeResolution.SelectedItem.ToString().Split(' ');

                            // Write the value to fsx.cfg
                            iniFile.WriteValue("GRAPHICS", "TEXTURE_MAX_LOAD", selectedItem[0].ToString());

                            // Null the form owner (.Net 1.1 -> 2.0 workaround)
                            Form formOwner = this.Owner;
                            this.Owner = null;

                            // Show the apply box
                            Apply apply = new Apply(selectedItem[0].ToString());
                            apply.ShowDialog();

                            // Reset the form owner
                            this.Owner = formOwner;
                        }
                        else
                        {
                            MessageBox.Show("Please select a resolution to apply from the resolutions drop down box",
                                "Unable to set resolution", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Your fsx.exe file could not be located. Please make sure you have selected your correct fsx.exe folder.",
                            "Unable to find fsx.exe", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("Your fsx.cfg file could not be located. Please make sure you have run FSX at least once before trying to apply a resolution.",
                        "Unable to find fsx.cfg", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
开发者ID:StevenFrost,项目名称:Editors,代码行数:70,代码来源:Main.cs

示例6: Main


//.........这里部分代码省略.........
            #endregion

            #region Check INI Files

            using (IniFile iniFile = new IniFile())
            {
                /// <switch>current profile</switch>
                iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                if (!File.Exists(Application.StartupPath + @"\locations.ini"))
                {
                    // Copy the locations resource
                    File.Copy(Application.StartupPath + @"\Resources\locations.resource",
                        Application.StartupPath + @"\locations.ini", false);
                }

                if (!File.Exists(Application.StartupPath + iniFile.ReadValue("PROFILES", "0")))
                {
                    try
                    {
                        if (!Directory.Exists(Application.StartupPath + @"\Profiles\"))
                        {
                            Directory.CreateDirectory(Application.StartupPath + @"\Profiles\");
                        }

                        if (!File.Exists(Application.StartupPath + @"\Profiles\default.ini"))
                        {
                            // Copy the resource
                            File.Copy(Application.StartupPath + @"\Resources\profile.resource",
                                Application.StartupPath + @"\Profiles\default.ini", false);
                        }

                        // Write the new path value
                        iniFile.WriteValue("PROFILES", "0", @"\Profiles\default.ini");

                        // Success message
                        MessageBox.Show("The default profile specified in 'locations.ini' could not be found. A new one has been automatically generated.",
                            "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    catch
                    {
                        // Error message
                        MessageBox.Show("The default profile specified in 'locations.ini' could not be found and a new profile could not be generated. Please reinstall the Texture Max Load Editor.",
                            "Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            #endregion

            #region Check INI Variables

            using (IniFile iniFile = new IniFile())
            {
                using (Existence existence = new Existence())
                {
                    /// <switch>current profile</switch>
                    iniFile.IniPath = Application.StartupPath + @"\locations.ini";

                    if (!Directory.Exists(iniFile.ReadValue("LOCATIONS", "exe")) &&
                        !Directory.Exists(iniFile.ReadValue("LOCATIONS", "cfg")) &&
                        !Directory.Exists(iniFile.ReadValue("LOCATIONS", "self")))
                    {
                        // Require a locations reset
                        iniFile.WriteValue("GENERAL", "reset", "1");
                    }
开发者ID:StevenFrost,项目名称:Editors,代码行数:67,代码来源:Main.cs


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