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


C# IniFile.Save方法代码示例

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


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

示例1: FixTimestamps

        /// <summary>
        /// Sets the timestamps inside a UDK*.ini file's [IniVersion] section to match the file timestamps of the corresponding Default*.ini files and their base files.
        /// Optionally this can be limited to files where the timestamp is off by exactly one hour to fix the timestamps for the current daylight saving time.
        /// </summary>
        /// <param name="daylightSavingCorrectionOnly">Only fix timestamps when they are off by exactly 1 hour due to daylight saving changes</param>
        public void FixTimestamps(bool daylightSavingCorrectionOnly)
        {
            foreach (var udkIniFilePath in Directory.GetFiles(configFolder, "UDK*.ini"))
              {
            string defaultIniFilePath = Path.Combine(configFolder, "Default" + Path.GetFileName(udkIniFilePath).Substring(3));
            if (!File.Exists(defaultIniFilePath))
              continue;

            var ini = new IniFile(udkIniFilePath);
            var sec = ini.GetSection("IniVersion");
            if (sec == null)
              continue;

            bool saveFile = true;
            List<long> timestamps = new List<long>();
            CollectDefaultIniTimestamps(defaultIniFilePath, timestamps);
            for (int i = 0; i < timestamps.Count; i++)
            {
              var newTimestamp = timestamps[i];
              if (daylightSavingCorrectionOnly)
              {
            var oldTimestamp = (long) sec.GetDecimal(i.ToString());
            if (oldTimestamp != 0 && oldTimestamp != newTimestamp && Math.Abs(oldTimestamp - newTimestamp) != 3600)
            {
              saveFile = false;
              break;
            }
              }
              sec.Set(i.ToString(), newTimestamp.ToString());
            }

            if (saveFile)
              ini.Save();
              }
        }
开发者ID:ToxikkModdingTeam,项目名称:ToxikkServerLauncher,代码行数:40,代码来源:IniFixer.cs

示例2: LogActivateChange

 public LogActivateChange(string acRoot) {
     _cfgFile = Path.Combine(FileUtils.GetSystemCfgDirectory(acRoot), "assetto_corsa.ini");
     var iniFile = new IniFile(_cfgFile);
     _originalValue = iniFile["LOG"].GetPossiblyEmpty("SUPPRESS");
     iniFile["LOG"].Set("SUPPRESS", false);
     iniFile.Save();
 }
开发者ID:gro-ove,项目名称:actools,代码行数:7,代码来源:Showroom_ClassicShooter.cs

示例3: EncryptAndDecryptTest

        public void EncryptAndDecryptTest()
        {
            var file = new IniFile();
            var section = file.Sections.Add("Encrypt Test");
            section.Keys.Add("Key 1", "Value 1");
            section.Keys.Add("Key 2", "Value 2");

            var encryptedFile = new IniFile(new IniOptions() { EncryptionPassword = @"abcdef" });
            encryptedFile.Sections.Add(section.Copy(encryptedFile));

            var encryptedFileWriter = new StringWriter();
            encryptedFile.Save(encryptedFileWriter);
            var encryptedFileContent = encryptedFileWriter.ToString();

            Assert.IsFalse(encryptedFileContent.Contains("Encrypt Test"));
            Assert.IsFalse(encryptedFileContent.Contains("Key 1"));
            Assert.IsFalse(encryptedFileContent.Contains("Value 1"));
            Assert.IsFalse(encryptedFileContent.Contains("Key 2"));
            Assert.IsFalse(encryptedFileContent.Contains("Value 2"));

            encryptedFile.Sections.Clear();
            encryptedFile.Load(new StringReader(encryptedFileContent));

            Assert.AreEqual("Encrypt Test", encryptedFile.Sections[0].Name);
            Assert.AreEqual("Key 1", encryptedFile.Sections[0].Keys[0].Name);
            Assert.AreEqual("Value 1", encryptedFile.Sections[0].Keys[0].Value);
            Assert.AreEqual("Key 2", encryptedFile.Sections[0].Keys[1].Name);
            Assert.AreEqual("Value 2", encryptedFile.Sections[0].Keys[1].Value);
        }
开发者ID:javadib,项目名称:MadMilkman.Ini,代码行数:29,代码来源:IniFileEncryptionCompressionTests.cs

示例4: ScreenshotFormatChange

 public ScreenshotFormatChange(string acRoot, string value) {
     _cfgFile = Path.Combine(FileUtils.GetSystemCfgDirectory(acRoot), "assetto_corsa.ini");
     var iniFile = new IniFile(_cfgFile);
     _originalFormat = iniFile["SCREENSHOT"].GetPossiblyEmpty("FORMAT");
     iniFile["SCREENSHOT"].Set("FORMAT", value);
     iniFile.Save();
 }
开发者ID:gro-ove,项目名称:actools,代码行数:7,代码来源:TemporaryChange.cs

示例5: LoadSettings

        private void LoadSettings()
        {
            try
            {

                if (defaultSettings) // Generate Settings
                {
                    iniFile = new IniFile();
                    iniFile.Section("General").Comment = "Configuration File for CL Studio Graph Editor";
                    iniFile.Section("General").Set("Theme", "Dark");
                    iniFile.Section("General").Set("Debug", "True", comment: "Enables debug view.");
                    iniFile.Section("View").Set("ShowGrid", "True");
                    iniFile.Section("View").Set("GridPadding", "400");
                    iniFile.Section("Service").Set("APIV1", "http://localhost:5555/");
                    iniFile.Save("data/config.ini");
                    //toolStripStatusLabel1.Text = "Settings Loaded...";
                }
                else
                { // Use file...
                    iniFile = new IniFile("data/config.ini");
                    // iniFile.Section("General").Get("Theme"); 
                    // iniFile.Section("General").Get("Debug");
                    //foreach (var section in iniFile.Sections())
                    //  MessageBox.Show(iniFile.Section("General").Get("Debug"));
                }
            }
            catch(Exception ex)
            {
                // ERROR SETTING DEFUALT SETTINGS
                MessageBox.Show("Error Loading Settings...");
            }


            m_MouseLoc = Point.Empty;
        }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:35,代码来源:LayoutEditor.cs

示例6: DistanceChange

 public DistanceChange(double value) {
     _cfgFile = FileUtils.GetCfgShowroomFilename();
     var iniFile = new IniFile(_cfgFile);
     _originalValue = iniFile["SETTINGS"].GetPossiblyEmpty("CAMERA_DISTANCE");
     iniFile["SETTINGS"].Set("CAMERA_DISTANCE", value);
     iniFile.Save();
 }
开发者ID:gro-ove,项目名称:actools,代码行数:7,代码来源:Showroom_ClassicShooter.cs

示例7: CompressAndDecompressTest

        public void CompressAndDecompressTest()
        {
            var file = new IniFile();
            var section = file.Sections.Add("Compression Test");
            for (int i = 0; i < 1000; i++)
                section.Keys.Add(
                    new IniKey(file, "Key " + i, Guid.NewGuid().ToString()));

            var compressedFile = new IniFile(new IniOptions() { Compression = true });
            compressedFile.Sections.Add(section.Copy(compressedFile));

            var fileStream = new MemoryStream();
            file.Save(fileStream);
            var compressedFileStream = new MemoryStream();
            compressedFile.Save(compressedFileStream);

            Assert.That(compressedFileStream.Length, Is.LessThan(fileStream.Length));

            compressedFile.Sections.Clear();
            compressedFile.Load(compressedFileStream);

            Assert.AreEqual(file.Sections[0].Name, compressedFile.Sections[0].Name);
            for (int i = 0; i < file.Sections[0].Keys.Count; i++)
            {
                Assert.AreEqual(file.Sections[0].Keys[i].Name, compressedFile.Sections[0].Keys[i].Name);
                Assert.AreEqual(file.Sections[0].Keys[i].Value, compressedFile.Sections[0].Keys[i].Value);
            }
        }
开发者ID:javadib,项目名称:MadMilkman.Ini,代码行数:28,代码来源:IniFileEncryptionCompressionTests.cs

示例8: Replace

 protected void Replace(IniFile ini, bool backup = false) {
     _saving = false;
     IgnoreChangesForAWhile();
     ini.Save(Filename, backup);
     Ini = ini;
     IsLoading = true;
     LoadFromIni();
     IsLoading = false;
 }
开发者ID:gro-ove,项目名称:actools,代码行数:9,代码来源:IniSettings.cs

示例9: SaveIniFileContent

        public static string[] SaveIniFileContent(IniFile file, IniOptions options)
        {
            string iniFileContent;
            using (var stream = new MemoryStream())
            {
                file.Save(stream);
                iniFileContent = new StreamReader(stream, options.Encoding).ReadToEnd();
            }

            return iniFileContent.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
        }
开发者ID:javadib,项目名称:MadMilkman.Ini,代码行数:11,代码来源:IniUtilities.cs

示例10: ExportIni

        private void ExportIni(string filename, string fbxName = null) {
            var iniFile = new IniFile(filename);
            ExportIni_Header(iniFile);
            ExportIni_Materials(iniFile);

            if (fbxName != null) {
                ExportIni_Nodes(iniFile, fbxName);
            }

            iniFile.Save();
        }
开发者ID:gro-ove,项目名称:actools,代码行数:11,代码来源:Kn5_ExportFbxIni.cs

示例11: SetOverride

        protected override bool SetOverride(WeatherObject weather) {
            _replacement = Path.Combine(weather.Location, "filter.ini");
            if (!File.Exists(_replacement)) return false;

            _destination = Destination;
            if (File.Exists(_destination)) {
                File.Delete(_destination);
            }
            
            FileUtils.Hardlink(_replacement, _destination);

            var ini = new IniFile(FileUtils.GetCfgVideoFilename());
            var section = ini["POST_PROCESS"];
            section.Set("__OGIRINAL_FILTER", section.GetNonEmpty("FILTER"));
            section.Set("FILTER", FilterId);
            ini.Save();

            return true;
        }
开发者ID:gro-ove,项目名称:actools,代码行数:19,代码来源:WeatherSpecificPpFilterHelper.cs

示例12: Revert

        public static void Revert() {
            if (AcRootDirectory.Instance.Value == null) return;

            try {
                var destination = Destination;
                if (!File.Exists(destination)) return;

                File.Delete(destination);

                var ini = new IniFile(FileUtils.GetCfgVideoFilename());
                var section = ini["POST_PROCESS"];
                if (section.GetNonEmpty("FILTER") != FilterId) return;

                section.Set("FILTER", section.GetNonEmpty("__OGIRINAL_FILTER") ?? @"default");
                ini.Save();
            } catch (Exception e) {
                Logging.Warning("Revert(): " + e);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:19,代码来源:WeatherSpecificPpFilterHelper.cs

示例13: Awake

    protected void Awake()
    {
        string defaultIniPath = Application.dataPath + "/" + IniFileName;
        string userIniPath = Application.persistentDataPath + "/" + IniFileName;

        // Copy INI file with default settings to user INI file if one doesn't exist
        if (File.Exists(defaultIniPath) && !File.Exists(userIniPath))
            File.Copy(defaultIniPath, userIniPath);

        // Load settings from INI file
        IniFile iniFile = new IniFile(userIniPath);

        m_title = iniFile["Settings", "Title", m_title];
        m_connectionString = iniFile["Settings", "ConnectionString", m_connectionString];
        m_filterExpression = iniFile["Settings", "FilterExpression", m_filterExpression];
        m_lineWidth = int.Parse(iniFile["Settings", "LineWidth", m_lineWidth.ToString()]);
        m_lineDepthOffset = float.Parse(iniFile["Settings", "LineDepthOffset", m_lineDepthOffset.ToString()]);
        m_pointsInLine = int.Parse(iniFile["Settings", "PointsInLine", m_pointsInLine.ToString()]);
        m_legendFormat = iniFile["Settings", "LegendFormat", m_legendFormat];
        m_statusRows = int.Parse(iniFile["Settings", "StatusRows", m_statusRows.ToString()]);
        m_statusDisplayInterval = double.Parse(iniFile["Settings", "StatusDisplayInterval", m_statusDisplayInterval.ToString()]);
        m_startTime = iniFile["Settings", "StartTime", m_startTime];
        m_stopTime = iniFile["Settings", "StopTime", m_stopTime];

        // Attempt to save INI file updates (e.g., to restore any missing settings)
        try
        {
            iniFile.Save();
        }
        catch (Exception ex)
        {
            Debug.Log("ERROR: " + ex.Message);
        }

        // Attempt to reference active mouse orbit script
        m_mouseOrbitScript = GetComponent<MouseOrbit>();

        // Create line dictionary and data queue
        m_scales = new ConcurrentDictionary<string, Scale>();
        m_dataLines = new ConcurrentDictionary<Guid, DataLine>();
        m_dataQueue = new ConcurrentQueue<ICollection<IMeasurement>>();
        m_legendLines = new List<LegendLine>();

        // Initialize status rows and timer to hide status after a period of no updates
        m_statusText = new string[m_statusRows];

        for (int i = 0; i < m_statusRows; i++)
        {
            m_statusText[i] = "";
        }

        m_hideStatusTimer = new System.Timers.Timer();
        m_hideStatusTimer.AutoReset = false;
        m_hideStatusTimer.Interval = m_statusDisplayInterval;
        m_hideStatusTimer.Elapsed += m_hideStatusTimer_Elapsed;

        // For mobile applications we use a larger GUI font size.
        // Other deployments might benefit from this as well - larger
        // size modes may work also but are not tested
        switch (Application.platform)
        {
            case RuntimePlatform.Android:
            case RuntimePlatform.IPhonePlayer:
                if (Screen.height <= 720)
                    m_guiSize = 2;	// 720P
                else
                    m_guiSize = 3;	// 1080P or higher
                break;
        }

        // Create a solid background for the control window
        m_controlWindowTexture = new Texture2D(1, 1);
        m_controlWindowTexture.SetPixel(0, 0, new Color32(10, 25, 70, 255));
        m_controlWindowTexture.Apply();

        VectorLine.SetCanvasCamera(Camera.main);
        VectorLine.canvas3D.hideFlags = HideFlags.HideInHierarchy;
    }
开发者ID:rmc00,项目名称:gsf,代码行数:78,代码来源:GraphLines.cs

示例14: Dispose

 public void Dispose() {
     var iniFile = new IniFile(_cfgFile);
     iniFile["SCREENSHOT"].Set("FORMAT", _originalFormat);
     iniFile.Save();
 }
开发者ID:gro-ove,项目名称:actools,代码行数:5,代码来源:TemporaryChange.cs

示例15: mainServer_messageHandler

        //
        //
        public static void mainServer_messageHandler(object sender, NewMessageEventsArgs e)
        {
            networkBusy = true;
            Log.WriteLineMessage(e.NewMessage);
            string sendMsg = string.Empty;
            string[] message;
            string[] Msg;

            message = e.NewMessage.Split(','); // first index contains the command
            // Make a command parser.
            //
            switch(message[0])
            {
                //
                // Main Menu
                case "Information":
                    sendMsg = string.Empty;
                    sendMsg = string.Format("{0},{1},{2},{3},{4},{5}",
                        RCServo.CPU(), RCServo.Version(), Convert.ToString(RCServo.Connected),
                        Convert.ToString(I2C.Connected),
                        Convert.ToString(AD7918.Connected),
                        Convert.ToString(SPI.Connected));
                    break;
                case "Options":
                    switch (message[1])
                    {
                        case "Read":
                            string tmp = string.Empty;
                            sendMsg = Server.MainIni.MotionReplay.ToString() + "," +
                                      Server.MainIni.EnableRemoteControl.ToString() + "," +
                                      Server.MainIni.PowerUpMotion + "," +
                                      Server.MainIni.LowPowerMotion + "," +
                                      Server.MainIni.LowPowerVoltage.ToString() + "," +
                                      Server.MainIni.TimeBase.ToString();
                            for (int i = 0; i < StaticUtilities.numberOfServos; i++)
                            {
                                tmp += string.Format(",{0}", Server.MainIni.ChannelFunction[i]);
                            }
                            sendMsg = sendMsg + tmp;
                            break;
                        case "Write":
                            Server.MainIni.MotionReplay = Convert.ToBoolean(message[2]);
                            Server.MainIni.EnableRemoteControl = Convert.ToBoolean(message[3]);
                            Server.MainIni.PowerUpMotion = Convert.ToInt32(message[4]);
                            Server.MainIni.LowPowerMotion = Convert.ToInt32(message[5]);
                            Server.MainIni.LowPowerVoltage = Convert.ToInt32(message[6]);
                            Server.MainIni.TimeBase = Convert.ToInt32(message[7]);
                            int[] temp = new int[StaticUtilities.numberOfServos];
                            for (int i = 0; i < StaticUtilities.numberOfServos; i++)
                            {
                                temp[i] = Convert.ToInt32(message[8 + i]);
                            }
                            Server.MainIni.ChannelFunction = temp;
                            Server.MainIni.Save();
                            Server.RCServo.Close();
                            Server.RCServo.Init();

                            if (MainIni.EnableRemoteControl)
                                if (!Server.XBox360.Open)
                                    Server.XBox360.Init();

                            sendMsg = "Ok";
                            break;
                        default:
                            break;
                    }
                    break;
                case "ReadMotionFile":
                    switch(message[1])
                    {
                        case "Open":
                            // Get the selected motion index and check
                            // in the motiontable if the motion exists
                            // return true if the file exist.
                            selectedMotionIndex = Convert.ToInt32(message[2]) + 1;
                            string file = Server.Table.MotionTable["Motion" + selectedMotionIndex.ToString()]["Filename"];
                            if (file != string.Empty)
                            {
                                khr_1hv_motion = new IniFile(file);
                                khr_1hv_motion.Load();
                                sendMsg = "Ok";
                            }
                            else
                            {
                                sendMsg = "No motion to read";
                            }
                            break;
                        case "GraphicalEdit":
                            Msg = new string[8];
                            Msg[0] = khr_1hv_motion["GraphicalEdit"]["Type"];
                            Msg[1] = khr_1hv_motion["GraphicalEdit"]["Width"];
                            Msg[2] = khr_1hv_motion["GraphicalEdit"]["Height"];
                            Msg[3] = khr_1hv_motion["GraphicalEdit"]["Items"];
                            Msg[4] = khr_1hv_motion["GraphicalEdit"]["Links"];
                            Msg[5] = khr_1hv_motion["GraphicalEdit"]["Start"];
                            Msg[6] = khr_1hv_motion["GraphicalEdit"]["Name"];
                            Msg[7] = khr_1hv_motion["GraphicalEdit"]["Ctrl"];
                            Items = 0;
//.........这里部分代码省略.........
开发者ID:tejastank,项目名称:KHR-1HV-Server,代码行数:101,代码来源:Program.cs


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