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


C# FileIniDataParser.WriteFile方法代码示例

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


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

示例1: ConfigHandler

        //constructor
        public ConfigHandler()
        {            
            FileIniDataParser Parser = new FileIniDataParser();

            string configDir = String.Format(@"{0}\config", GetLocalDir());
            string configPath = String.Format(@"{0}\config\launcherConfig.ini", GetLocalDir());

            //release 0.0.
            string defaultLauncherVersion = "0.0.3";

            if (!Directory.Exists(configDir))
            {
                Directory.CreateDirectory(configDir);
            }
            if (!File.Exists(configPath))
            {
                //here we create a new empty file
                FileStream configStream = File.Create(configPath);
                configStream.Close();

                //read the file as an INI file
                try
                {
                    IniData data = Parser.ReadFile(configPath);

                    data.Sections.AddSection("Local");
                    data.Sections.AddSection("Remote");
                    data.Sections.AddSection("Launchpad");

                    data["Local"].AddKey("launcherVersion", defaultLauncherVersion);
                    data["Local"].AddKey("gameName", "Example");
                    data["Local"].AddKey("systemTarget", "Win64");

                    data["Remote"].AddKey("FTPUsername", "anonymous");
                    data["Remote"].AddKey("FTPPassword", "anonymous");
                    data["Remote"].AddKey("FTPUrl", "ftp://example.example.com");

                    data["Launchpad"].AddKey("bOfficialUpdates", "true");

                    Parser.WriteFile(configPath, data);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                
            }
            else 
            {
                IniData data = Parser.ReadFile(configPath);
                data["Local"]["launcherVersion"] = defaultLauncherVersion;

                Parser.WriteFile(configPath, data);
            }
        }
开发者ID:GearGadgetStudios,项目名称:Launchpad,代码行数:56,代码来源:ConfigHandler.cs

示例2: WriteConfig

		/// <summary>
		/// Writes the config data to disk. This method is thread-blocking, and all write operations 
		/// are synchronized via lock(WriteLock).
		/// </summary>
		/// <param name="Parser">The parser dealing with the current data.</param>
		/// <param name="Data">The data which should be written to file.</param>
		private void WriteConfig(FileIniDataParser Parser, IniData Data)
		{
			lock (WriteLock)
			{
				Parser.WriteFile (GetConfigPath (), Data);
			}
		}
开发者ID:furesoft,项目名称:Launchpad,代码行数:13,代码来源:ConfigHandler.cs

示例3: defaultip_Click

        private void defaultip_Click(object sender, EventArgs e)
        {
            var parser = new FileIniDataParser();
            var data = parser.ReadFile("DefaultService.ini");
            data["KR_REAL"]["AUTH_DOMAIN"] = "auth.black.game.daum.net";
            File.Delete("DefaultService.ini");
            parser.WriteFile("DefaultService.ini", data);

            serverIP.Text = @"auth.black.game.daum.net";
            serverIP.ForeColor = Color.Green;

            data = parser.ReadFile("service.ini");
            data["KR"]["AUTHENTIC_DOMAIN"] = "blackauth.black.game.daum.net";
            File.Delete("service.ini");
            parser.WriteFile("service.ini", data);

            authip.Text = @"blackauth.black.game.daum.net";
            authip.ForeColor = Color.Green;
        }
开发者ID:arkanoid1,项目名称:BlackDesert,代码行数:19,代码来源:Form1.cs

示例4: change_Click

        private void change_Click(object sender, EventArgs e)
        {
            var parser = new FileIniDataParser();
            var data = parser.ReadFile("DefaultService.ini");
            data["KR_REAL"]["AUTH_DOMAIN"] = ip1.Text;
            File.Delete("DefaultService.ini");
            parser.WriteFile("DefaultService.ini", data);

            serverIP.Text = ip1.Text;
            serverIP.ForeColor = Color.Red;

            data = parser.ReadFile("service.ini");
            data["KR"]["AUTHENTIC_DOMAIN"] = ip2.Text;
            File.Delete("service.ini");
            parser.WriteFile("service.ini", data);

            authip.Text = ip2.Text;
            authip.ForeColor = Color.Red;
        }
开发者ID:arkanoid1,项目名称:BlackDesert,代码行数:19,代码来源:Form1.cs

示例5: SaveBtn_Click

        private void SaveBtn_Click(object sender, EventArgs e)
        {
            FileIniDataParser i = new FileIniDataParser();
            i.Parser.Configuration.CommentString = "#";
            IniData data = i.ReadFile(Preferences.GetConfig());

            data["DS"][AppID] = NewDbName.Text;
            retText = NewDbName.Text;

            i.WriteFile(Preferences.GetConfig(), data);

            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
开发者ID:NiDragon,项目名称:IllTechLibrary,代码行数:14,代码来源:DBSelect.cs

示例6: Save

        public void Save(SemanticVersion version, string name, DllReference parentAssembly)
        {
            var parser = new FileIniDataParser();
            var versionsFileData = new IniData();

            versionsFileData.Sections.AddSection("Dependency");
            versionsFileData.Sections["Dependency"].AddKey("version", version.ToString());
            versionsFileData.Sections["Dependency"].AddKey("name", name);
            
            if(!Directory.Exists("cache"))
                Directory.CreateDirectory("cache");

            parser.WriteFile(@"cache\" + parentAssembly.Id.Item1 + _sectionSeparator + parentAssembly.Id.Item2 + _sectionSeparator + name + ".ini", versionsFileData);
        }
开发者ID:Ullink,项目名称:NugetConverter,代码行数:14,代码来源:DependenciesResolverSerializer.cs

示例7: AddUnresolvedDependencies

        public void AddUnresolvedDependencies(AssemblyReference parentAssembly)
        {
            var parser = new FileIniDataParser();
            var versionsFileData = new IniData();

            if (!Directory.Exists(@"cache\unresolved"))
                Directory.CreateDirectory(@"cache\unresolved");

            var file = @"cache\unresolved\" + parentAssembly.Item2 + _sectionSeparator + parentAssembly.Item1 + ".ini";
            if (File.Exists(file))
                return;

            parser.WriteFile(file, versionsFileData);
        }
开发者ID:Ullink,项目名称:NugetConverter,代码行数:14,代码来源:DependenciesResolverSerializer.cs

示例8: Main

        public static void Main()
        {
            //Create an instance of a ini file parser
            FileIniDataParser fileIniData = new FileIniDataParser();

            if (File.Exists("NewTestIniFile.ini"))
                File.Delete("NewTestIniFile.ini");

            // This is a special ini file where we use the '#' character for comment lines
            // instead of ';' so we need to change the configuration of the parser:
            fileIniData.Parser.Configuration.CommentString = "#";

            //Parse the ini file
            IniData parsedData = fileIniData.ReadFile("TestIniFile.ini");

            //Write down the contents of the ini file to the console
            Console.WriteLine("---- Printing contents of the INI file ----\n");
            Console.WriteLine(parsedData);
            Console.WriteLine();

            //Get concrete data from the ini file
            Console.WriteLine("---- Printing setMaxErrors value from GeneralConfiguration section ----");
            Console.WriteLine("setMaxErrors = " + parsedData["GeneralConfiguration"]["setMaxErrors"]);
            Console.WriteLine();

            //Modify the INI contents and save
            Console.WriteLine();

            // Modify the loaded ini file
            IniData modifiedParsedData = ModifyINIData(parsedData);

            //Write down the contents of the modified ini file to the console
            Console.WriteLine("---- Printing contents of the new INI file ----");
            Console.WriteLine(modifiedParsedData);
            Console.WriteLine();

            //Save to a file
            Console.WriteLine("---- Saving the new ini file to the file NewTestIniFile.ini ----");
            Console.WriteLine();

            // Uncomment this to change the new line string used to write the ini file to disk to
            // force use the windows style new line
            //modifiedParsedData.Configuration.NewLineStr = "\r\n";
            fileIniData.WriteFile("NewTestIniFile.ini", modifiedParsedData);
        }
开发者ID:rickyah,项目名称:ini-parser,代码行数:45,代码来源:Program.cs

示例9: Locate

 public static void Locate()
 {
     FileIniDataParser parser = new FileIniDataParser();
     IniData data = parser.ReadFile("config.ini");
     for (int i = 1; i <= 17; i++)
     {
         if (MessageBox.Show("Please set the cursor on your collector number " + i + " and press enter. Click on cancel if not available", "Collectors localization", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             Point collectorPos = FindCursorPos();
             data["collectors"]["collector" + i] = collectorPos.X + ";" + collectorPos.Y;
             Home.bsProcess.mouse.SendClick(WButton.Left, collectorPos, false);
         }
         else
             data["collectors"]["collector" + i] = "-1;-1";
     }
     parser.WriteFile("config.ini", data);
     Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0,0), false);
 }
开发者ID:Jeremymav,项目名称:ClashofBots,代码行数:18,代码来源:LocateCollectors.cs

示例10: flatCheckBox_trophy_CheckedChanged

 private void flatCheckBox_trophy_CheckedChanged(object sender)
 {
     FileIniDataParser parser = new FileIniDataParser();
     IniData data = parser.ReadFile("config.ini");
     data["search"]["btrophy"] = flatCheckBox_trophy.Checked.ToString();
     parser.WriteFile("config.ini", data);
 }
开发者ID:Jeremymav,项目名称:ClashofBots,代码行数:7,代码来源:Home.cs

示例11: RegisterURLHandler_Linux

        private static void RegisterURLHandler_Linux()
        {
            var parser = new FileIniDataParser();
            IniData data;

            log.InfoFormat("Trying to register URL handler");

            if (!File.Exists(MimeAppsListPath))
            {
                log.InfoFormat("{0} does not exist, trying to create it", MimeAppsListPath);
                File.WriteAllLines(MimeAppsListPath, new string[] { "[Default Applications]" });
            }

            try
            {
                data = parser.ReadFile(MimeAppsListPath);
            }
            catch (DirectoryNotFoundException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }
            catch (FileNotFoundException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }
            catch (ParsingException ex)
            {
                log.InfoFormat("Skipping URL handler: {0}", ex.Message);
                return;
            }

            if (data["Added Associations"] == null)
            {
                data.Sections.AddSection("Added Associations");
            }
            data["Added Associations"].RemoveKey("x-scheme-handler/ckan");
            data["Added Associations"].AddKey("x-scheme-handler/ckan", HandlerFileName);

            parser.WriteFile(MimeAppsListPath, data);

            var handlerPath = Path.Combine(ApplicationsPath, HandlerFileName);
            var handlerDirectory = Path.GetDirectoryName(handlerPath);

            if (handlerDirectory == null || !Directory.Exists(handlerDirectory))
            {
                log.ErrorFormat("Error: {0} doesn't exist", handlerDirectory);
                return;
            }

            if (File.Exists(handlerPath))
            {
                File.Delete(handlerPath);
            }

            File.WriteAllText(handlerPath, "");
            data = parser.ReadFile(handlerPath);
            data.Sections.AddSection("Desktop Entry");
            data["Desktop Entry"].AddKey("Version", "1.0");
            data["Desktop Entry"].AddKey("Type", "Application");
            data["Desktop Entry"].AddKey("Exec", "mono " + System.Reflection.Assembly.GetExecutingAssembly().Location + " gui %u");
            data["Desktop Entry"].AddKey("Icon", "ckan");
            data["Desktop Entry"].AddKey("StartupNotify", "true");
            data["Desktop Entry"].AddKey("Terminal", "false");
            data["Desktop Entry"].AddKey("Categories", "Utility");
            data["Desktop Entry"].AddKey("MimeType", "x-scheme-handler/ckan");
            data["Desktop Entry"].AddKey("Name", "CKAN Launcher");
            data["Desktop Entry"].AddKey("Comment", "Launch CKAN");

            parser.WriteFile(handlerPath, data);
            AutoUpdate.SetExecutable(handlerPath);
        }
开发者ID:Wetmelon,项目名称:CKAN,代码行数:73,代码来源:URLHandlers.cs

示例12: flatNumeric_deployTime_ValueChange

 private void flatNumeric_deployTime_ValueChange(object sender, EventArgs e)
 {
     FileIniDataParser parser = new FileIniDataParser();
     IniData data = parser.ReadFile("config.ini");
     data["attack"]["deploytime"] = flatNumeric_deployTime.Value.ToString();
     parser.WriteFile("config.ini", data);
 }
开发者ID:Jeremymav,项目名称:ClashofBots,代码行数:7,代码来源:Home.cs

示例13: LangCreate

		void LangCreate()
		{
			var parser = new FileIniDataParser();
			IniData data = new IniData();

			data.Sections.AddSection("info");
			data.Sections["info"].AddKey("Code", "en"); // file id
			data.Sections["info"].AddKey("Name", "English");
			data.Sections["info"].AddKey("Author", "Anime4000");
			data.Sections["info"].AddKey("Version", $"{Global.App.VersionRelease}");
			data.Sections["info"].AddKey("Contact", "https://github.com/Anime4000");
			data.Sections["info"].AddKey("Comment", "Please refer IETF Language Tag here: http://www.i18nguy.com/unicode/language-identifiers.html");

			data.Sections.AddSection(Name);
			Control ctrl = this;
			do
			{
				ctrl = GetNextControl(ctrl, true);

				if (ctrl != null)
					if (ctrl is Label ||
						ctrl is Button ||
						ctrl is TabPage ||
						ctrl is CheckBox ||
						ctrl is RadioButton ||
						ctrl is GroupBox)
						if (!string.IsNullOrEmpty(ctrl.Text))
							data.Sections[Name].AddKey(ctrl.Name, ctrl.Text.Replace("\n", "\\n").Replace("\r", ""));

			} while (ctrl != null);

			foreach (ToolStripItem item in cmsQueueMenu.Items)
				if (item is ToolStripMenuItem)
					data.Sections[Name].AddKey(item.Name, item.Text);

			foreach (ToolStripItem item in tsmiQueueAviSynth.DropDownItems)
				if (item is ToolStripMenuItem)
					data.Sections[Name].AddKey(item.Name, item.Text);

			foreach (ColumnHeader item in lstQueue.Columns)
				data.Sections[Name].AddKey($"{item.Tag}", item.Text);

			foreach (ColumnHeader item in lstSub.Columns)
				data.Sections[Name].AddKey($"{item.Tag}", item.Text);

			foreach (ColumnHeader item in lstAttach.Columns)
				data.Sections[Name].AddKey($"{item.Tag}", item.Text);

			data.Sections.AddSection(Name);
			data.Sections[Name].AddKey("BenchmarkDownload", Language.BenchmarkDownload);
			data.Sections[Name].AddKey("BenchmarkNoFile", Language.BenchmarkNoFile);
			data.Sections[Name].AddKey("NotSupported", Language.NotSupported);
			data.Sections[Name].AddKey("OneItem", Language.OneItem);
			data.Sections[Name].AddKey("OneVideo", Language.OneVideo);
			data.Sections[Name].AddKey("SaveNewProfilesInfo", Language.SaveNewProfilesInfo);
			data.Sections[Name].AddKey("SaveNewProfilesTitle", Language.SaveNewProfilesTitle);
			data.Sections[Name].AddKey("SelectAviSynth", Language.SelectAviSynth);
			data.Sections[Name].AddKey("SelectNotAviSynth", Language.SelectNotAviSynth);
			data.Sections[Name].AddKey("SelectOneVideoAttch", Language.SelectOneVideoAttch);
			data.Sections[Name].AddKey("SelectOneVideoPreview", Language.SelectOneVideoPreview);
			data.Sections[Name].AddKey("SelectOneVideoSubtitle", Language.SelectOneVideoSubtitle);
			data.Sections[Name].AddKey("VideoToAviSynth", Language.VideoToAviSynth.Replace("\n", "\\n"));
			data.Sections[Name].AddKey("QueueSave", Language.QueueSave);
			data.Sections[Name].AddKey("QueueSaveError", Language.QueueSaveError);
			data.Sections[Name].AddKey("QueueOpenChange", Language.QueueOpenChange);
			data.Sections[Name].AddKey("Quit", Language.Quit);

			data.Sections[Name].AddKey("TipUpdateTitle", Language.TipUpdateTitle);
			data.Sections[Name].AddKey("TipUpdateMessage", Language.TipUpdateMessage);

			for (int i = 0; i < cboPictureYadifMode.Items.Count; i++)
				data.Sections[Name].AddKey($"DeInterlaceMode{i}", (string)cboPictureYadifMode.Items[i]);

			for (int i = 0; i < cboPictureYadifField.Items.Count; i++)
				data.Sections[Name].AddKey($"DeInterlaceField{i}", (string)cboPictureYadifField.Items[i]);

			for (int i = 0; i < cboPictureYadifFlag.Items.Count; i++)
				data.Sections[Name].AddKey($"DeInterlaceFlag{i}", (string)cboPictureYadifFlag.Items[i]);

			data.Sections[Name].AddKey("Untitled", Language.Untitled);
			data.Sections[Name].AddKey("Untitled", Language.Donate);

			parser.WriteFile(Path.Combine(Global.Folder.Language, "en.ini"), data, Encoding.UTF8);		
		}
开发者ID:marcomanieri,项目名称:IFME,代码行数:84,代码来源:frmMain.cs

示例14: SaveSettings

 public void SaveSettings(string fileName)
 {
     if (ParsedConfig == null)
         ParsedConfig = new IniData();
     // Note that this will persist the merged global & user configurations, not the original global config.
     // Since we don't call this method from production code, this is not an issue.
     // TODO: parserConfig is also created in ParseFiles. Consider making it a static member for consistency.
     var parserConfig = new IniParserConfiguration {
         // ThrowExceptionsOnError = false,
         CommentString = "#",
         SkipInvalidLines = true
     };
     var parser = new IniDataParser(parserConfig);
     var fileParser = new FileIniDataParser(parser);
     var utf8 = new UTF8Encoding(false);
     fileParser.WriteFile(fileName, ParsedConfig, utf8);
 }
开发者ID:ermshiperete,项目名称:LfMerge,代码行数:17,代码来源:LfMergeSettingsIni.cs

示例15: SetPrefs

        public static void SetPrefs(String Key, String Value)
        {
            FileIniDataParser i = new FileIniDataParser();
            i.Parser.Configuration.CommentString = "#";
            IniData data = i.ReadFile(GetConfig());

            data["PREFS"][Key] = Value;

            i.WriteFile(GetConfig(), data);
        }
开发者ID:NiDragon,项目名称:IllTechLibrary,代码行数:10,代码来源:Preferences.cs


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