{"id":268778,"date":"2015-11-23T14:26:12","date_gmt":"2015-11-23T11:26:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=268778"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=268778","title":{"rendered":"C#, \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b"},"content":{"rendered":"<p>       <habracut\/>  <\/p>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u043a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0445 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h4>C# \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 Properties.Settings<\/h4>\n<p>  <b>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e Properties.Settings<\/b><\/p>\n<p>  \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Properties.Settings \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 xml \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<p>  \u0421:\\ Users \\ [user name] \\ AppData \\ Local \\ [ (Project Name) or (AssemblyCompany) ] \\ [name project_cashBuild] \\ [AssemblyVersion] \\ user.config<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f Properties.Settings. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 Properties -&gt; Settings.settings:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Properties -&gt; Settings.settings in VS 2013<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1ad\/9ac\/439\/1ad9ac439429478780ad37746b82b886.png\"\/>  <\/div>\n<\/div>\n<p>  \u042f \u0441\u043e\u0437\u0434\u0430\u043b 3-\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0432\u044b\u0431\u0440\u0430\u043b \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f: 2- \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 1- \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <\/p>\n<p>  <i>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u044b. \u041e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u0442\u044c, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u2014 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0447\u0438\u0442\u0430\u0442\u044c.<\/i><br \/>  <habracut\/><br \/>  <i><u>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c:<\/u><\/i><\/p>\n<ul>\n<li>Version \u2014 \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0435\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0422.\u043a. \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u0443\u043a\u0432\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, b \u2014 \u043e\u0442 beta). \u0410 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043b, \u0447\u0442\u043e\u0431 \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0430\u0448\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0442.\u043a. AssemblyVersion \u0440\u0435\u0434\u043a\u043e \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442).<\/li>\n<li>Save_text \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0430\u0448 \u0442\u0435\u043a\u0441\u0442.<\/li>\n<li>open_sum \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/li>\n<\/ul>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 Form1.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">namespace Habrahabr {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();             this.Text += &quot; &quot; + Properties.Settings.Default.Version; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0432\u0435\u0440\u0441\u0438\u044e.             Properties.Settings.Default.open_sum++; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c +1 \u043a \u043a\u043e\u043b-\u0432\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.             label2.Text = Properties.Settings.Default.open_sum.ToString(); \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432 Label2 \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.             richTextBox1.Text = Properties.Settings.Default.Save_text; \/\/ \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442             Properties.Settings.Default.Save();  \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.         }          private void button1_Click(object sender, EventArgs e)         {             Properties.Settings.Default.Save_text = richTextBox1.Text; \/\/ \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 richTextBox1 \u0432 Save_text             Properties.Settings.Default.Save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.             MessageBox.Show(&quot;\u0422\u0435\u043a\u0441\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/b><\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0440\u0430\u0432\u043d\u043e 1. \u0418 \u0442\u0435\u0441\u0442\u0430 \u0432 richTextBox1 \u043d\u0435\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cc5\/d45\/5e0\/cc5d455e04a7428385c6b545ca2ecc96.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/08d\/44c\/be0\/08d44cbe0f524acf836eec0cfbedb2ee.png\"\/><\/p>\n<p>  \u041f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d, \u0438 \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0443\u0436\u0435 2-\u0432\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a82\/cf1\/095\/a82cf10953ce46f8a2f71d4b4a967fb0.png\"\/><\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434<\/b><\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434 \u0445\u043e\u0440\u043e\u0448, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431 \u0440\u044f\u0434\u043e\u0432\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u044b\u043b\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h4>C# \u0438 ini-\u0444\u0430\u0439\u043b\u044b<\/h4>\n<p>  \u0421 ini-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432\u0441\u0435 \u043d\u0430 \u043e\u0431\u043e\u0440\u043e\u0442, \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u043d\u0435-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0445\u043e\u0440\u043e\u0448, \u0435\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0437\u0430\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0433\u0440\u044b \u0431\u0435\u0437 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438 (\u0442\u043e\u0442\u0436\u0435 revLoader).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0448\u0435\u0439 \u0442\u0435\u043c\u0435. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00abIniFile\u00bb, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438), \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442:<\/p>\n<pre><code class=\"cs\">using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e-\u043f\u043e\u0440\u044f\u0434\u043a\u0443:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 IniFiles.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text;  namespace IniFiles {     class IniFile     {         string Path; \/\/\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430.          [DllImport(&quot;kernel32&quot;)] \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c kernel32.dll \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e WritePrivateProfilesString         static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);          [DllImport(&quot;kernel32&quot;)] \/\/ \u0415\u0449\u0435 \u0440\u0430\u0437 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c kernel32.dll, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetPrivateProfileString         static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);          \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u0438\u043c\u044f.         public IniFile(string IniPath)         {             Path = new FileInfo(IniPath).FullName.ToString();         }          \/\/\u0427\u0438\u0442\u0430\u0435\u043c ini-\u0444\u0430\u0439\u043b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438.         public string ReadINI(string Section, string Key)         {             var RetVal = new StringBuilder(255);             GetPrivateProfileString(Section, Key, &quot;&quot;, RetVal, 255, Path);             return RetVal.ToString();         }         \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 ini-\u0444\u0430\u0439\u043b. \u0417\u0430\u043f\u0438\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.         public void Write(string Section, string Key, string Value)         {             WritePrivateProfileString(Section, Key, Value, Path);         }          \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043a\u043b\u044e\u0447 \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438.         public void DeleteKey(string Key, string Section = null)         {             Write(Section, Key, null);         }         \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e         public void DeleteSection(string Section = null)         {             Write(Section, null, null);         }         \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u044e\u0447, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438         public bool KeyExists(string Key, string Section = null)         {             return ReadINI(Section, Key).Length &gt; 0;         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 Form1.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  namespace IniFiles {     public partial class Form1 : Form     {         IniFile INI = new IniFile(&quot;config.ini&quot;);         public Form1()         {             InitializeComponent();             auto_read();                         }          private void auto_read()         {             if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Width&quot;))                 numericUpDown2.Value = int.Parse(INI.ReadINI(&quot;SettingForm1&quot;, &quot;Height&quot;));             else                 numericUpDown1.Value = this.MinimumSize.Height;              if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Height&quot;))                 numericUpDown1.Value = int.Parse(INI.ReadINI(&quot;SettingForm1&quot;, &quot;Width&quot;));             else                 numericUpDown2.Value = this.MinimumSize.Width;              if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Width&quot;))                 textBox1.Text = INI.ReadINI(&quot;Other&quot;, &quot;Text&quot;);              this.Height = int.Parse(numericUpDown1.Value.ToString());             this.Width = int.Parse(numericUpDown2.Value.ToString());                      }                  private void button1_Click(object sender, EventArgs e)         {             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Height&quot;, numericUpDown2.Value.ToString());             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Width&quot;, numericUpDown1.Value.ToString());             INI.WriteINI(&quot;Other&quot;, &quot;Text&quot;, textBox1.Text);             MessageBox.Show(&quot;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SettingForm1 \u0438 Other \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.                   }          private void button2_Click(object sender, EventArgs e)         {             auto_read(); \/\/ \u0427\u0442\u043e\u0431 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.         }          private void button3_Click(object sender, EventArgs e)         {             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Height&quot;, numericUpDown2.Value.ToString());             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Width&quot;, numericUpDown1.Value.ToString());             this.Height = int.Parse(numericUpDown1.Value.ToString());             this.Width = int.Parse(numericUpDown2.Value.ToString());             MessageBox.Show(&quot;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SettingForm1 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.                      }                } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/b><\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0444\u0430\u0439\u043b\u0430 config.ini. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f fasle \u0438 \u043c\u044b \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043e\u043a\u043d\u043e \u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d6d\/1b9\/ffc\/d6d1b9ffc73a4942a647c4731014bdab.PNG\"\/><\/p>\n<p>  \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043a\u043d\u0430 \u0438 \u0436\u043c\u0435\u043c \u00ab\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c\u00bb<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e9f\/491\/e94\/e9f491e9461c409e87f6c6e7f829132f.PNG\"\/><\/p>\n<p>  \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b config.ini \u0440\u0443\u043a\u0430\u043c\u0438 \u0438 \u0436\u043c\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/353\/0a9\/3f4\/3530a93f4efb48fca63bfc13da41f9da.PNG\"\/><\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043e\u043f\u0438\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 xml \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/271483\/\"> http:\/\/habrahabr.ru\/post\/271483\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <habracut\/>  <\/p>\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u043a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0445 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h4>C# \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 Properties.Settings<\/h4>\n<p>  <b>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e Properties.Settings<\/b><\/p>\n<p>  \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Properties.Settings \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 xml \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<p>  \u0421:\\ Users \\ [user name] \\ AppData \\ Local \\ [ (Project Name) or (AssemblyCompany) ] \\ [name project_cashBuild] \\ [AssemblyVersion] \\ user.config<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f Properties.Settings. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 Properties -&gt; Settings.settings:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Properties -&gt; Settings.settings in VS 2013<\/b><\/p>\n<div class=\"spoiler_text\">  <\/div>\n<\/div>\n<p>  \u042f \u0441\u043e\u0437\u0434\u0430\u043b 3-\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0432\u044b\u0431\u0440\u0430\u043b \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f: 2- \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438 1- \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. <\/p>\n<p>  <i>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u043e\u0441\u0442\u044b. \u041e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u0442\u044c, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u2014 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0447\u0438\u0442\u0430\u0442\u044c.<\/i><br \/>  <habracut\/><br \/>  <i><u>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c:<\/u><\/i><\/p>\n<ul>\n<li>Version \u2014 \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0435\u0435 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0422.\u043a. \u0432\u0435\u0440\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0431\u0443\u043a\u0432\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, b \u2014 \u043e\u0442 beta). \u0410 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043b, \u0447\u0442\u043e\u0431 \u043d\u0435 \u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0430\u0448\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0442.\u043a. AssemblyVersion \u0440\u0435\u0434\u043a\u043e \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442).<\/li>\n<li>Save_text \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u043a\u0443\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043d\u0430\u0448 \u0442\u0435\u043a\u0441\u0442.<\/li>\n<li>open_sum \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/li>\n<\/ul>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 Form1.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">namespace Habrahabr {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();             this.Text += &quot; &quot; + Properties.Settings.Default.Version; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0432\u0435\u0440\u0441\u0438\u044e.             Properties.Settings.Default.open_sum++; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c +1 \u043a \u043a\u043e\u043b-\u0432\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.             label2.Text = Properties.Settings.Default.open_sum.ToString(); \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0432 Label2 \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.             richTextBox1.Text = Properties.Settings.Default.Save_text; \/\/ \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442             Properties.Settings.Default.Save();  \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.         }          private void button1_Click(object sender, EventArgs e)         {             Properties.Settings.Default.Save_text = richTextBox1.Text; \/\/ \u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 richTextBox1 \u0432 Save_text             Properties.Settings.Default.Save(); \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.             MessageBox.Show(&quot;\u0422\u0435\u043a\u0441\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/b><\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0440\u0430\u0432\u043d\u043e 1. \u0418 \u0442\u0435\u0441\u0442\u0430 \u0432 richTextBox1 \u043d\u0435\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  \u041f\u0440\u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d, \u0438 \u043a\u043e\u043b-\u0432\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0443\u0436\u0435 2-\u0432\u0430.<\/p>\n<p>  <b>\u0412\u044b\u0432\u043e\u0434<\/b><\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041c\u0435\u0442\u043e\u0434 \u0445\u043e\u0440\u043e\u0448, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435 \u043d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431 \u0440\u044f\u0434\u043e\u0432\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u044b\u043b\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h4>C# \u0438 ini-\u0444\u0430\u0439\u043b\u044b<\/h4>\n<p>  \u0421 ini-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432\u0441\u0435 \u043d\u0430 \u043e\u0431\u043e\u0440\u043e\u0442, \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u043d\u0435-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0445\u043e\u0440\u043e\u0448, \u0435\u0441\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0437\u0430\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0433\u0440\u044b \u0431\u0435\u0437 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438 (\u0442\u043e\u0442\u0436\u0435 revLoader).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u0448\u0435\u0439 \u0442\u0435\u043c\u0435. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0430\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043d\u0438\u043c. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00abIniFile\u00bb, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438), \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442:<\/p>\n<pre><code class=\"cs\">using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e-\u043f\u043e\u0440\u044f\u0434\u043a\u0443:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 IniFiles.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text;  namespace IniFiles {     class IniFile     {         string Path; \/\/\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430.          [DllImport(&quot;kernel32&quot;)] \/\/ \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c kernel32.dll \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e WritePrivateProfilesString         static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);          [DllImport(&quot;kernel32&quot;)] \/\/ \u0415\u0449\u0435 \u0440\u0430\u0437 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c kernel32.dll, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetPrivateProfileString         static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);          \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0441\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 \u0435\u0433\u043e \u0438\u043c\u044f.         public IniFile(string IniPath)         {             Path = new FileInfo(IniPath).FullName.ToString();         }          \/\/\u0427\u0438\u0442\u0430\u0435\u043c ini-\u0444\u0430\u0439\u043b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438.         public string ReadINI(string Section, string Key)         {             var RetVal = new StringBuilder(255);             GetPrivateProfileString(Section, Key, &quot;&quot;, RetVal, 255, Path);             return RetVal.ToString();         }         \/\/\u0417\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 ini-\u0444\u0430\u0439\u043b. \u0417\u0430\u043f\u0438\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.         public void Write(string Section, string Key, string Value)         {             WritePrivateProfileString(Section, Key, Value, Path);         }          \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043a\u043b\u044e\u0447 \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438.         public void DeleteKey(string Key, string Section = null)         {             Write(Section, Key, null);         }         \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e         public void DeleteSection(string Section = null)         {             Write(Section, null, null);         }         \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u044e\u0447, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438         public bool KeyExists(string Key, string Section = null)         {             return ReadINI(Section, Key).Length &gt; 0;         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 Form1.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  namespace IniFiles {     public partial class Form1 : Form     {         IniFile INI = new IniFile(&quot;config.ini&quot;);         public Form1()         {             InitializeComponent();             auto_read();                         }          private void auto_read()         {             if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Width&quot;))                 numericUpDown2.Value = int.Parse(INI.ReadINI(&quot;SettingForm1&quot;, &quot;Height&quot;));             else                 numericUpDown1.Value = this.MinimumSize.Height;              if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Height&quot;))                 numericUpDown1.Value = int.Parse(INI.ReadINI(&quot;SettingForm1&quot;, &quot;Width&quot;));             else                 numericUpDown2.Value = this.MinimumSize.Width;              if (INI.KeyExistsINI(&quot;SettingForm1&quot;, &quot;Width&quot;))                 textBox1.Text = INI.ReadINI(&quot;Other&quot;, &quot;Text&quot;);              this.Height = int.Parse(numericUpDown1.Value.ToString());             this.Width = int.Parse(numericUpDown2.Value.ToString());                      }                  private void button1_Click(object sender, EventArgs e)         {             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Height&quot;, numericUpDown2.Value.ToString());             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Width&quot;, numericUpDown1.Value.ToString());             INI.WriteINI(&quot;Other&quot;, &quot;Text&quot;, textBox1.Text);             MessageBox.Show(&quot;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SettingForm1 \u0438 Other \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.                   }          private void button2_Click(object sender, EventArgs e)         {             auto_read(); \/\/ \u0427\u0442\u043e\u0431 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f.         }          private void button3_Click(object sender, EventArgs e)         {             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Height&quot;, numericUpDown2.Value.ToString());             INI.WriteINI(&quot;SettingForm1&quot;, &quot;Width&quot;, numericUpDown1.Value.ToString());             this.Height = int.Parse(numericUpDown1.Value.ToString());             this.Width = int.Parse(numericUpDown2.Value.ToString());             MessageBox.Show(&quot;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SettingForm1 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b&quot;, &quot;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f&quot;, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); \/\/ \u0413\u043e\u0432\u043e\u0440\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442.                      }                } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/b><\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0444\u0430\u0439\u043b\u0430 config.ini. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f fasle \u0438 \u043c\u044b \u043f\u0440\u0438\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043e\u043a\u043d\u043e \u043a \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c.<\/p>\n<p>  \u041c\u0435\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u043a\u043d\u0430 \u0438 \u0436\u043c\u0435\u043c \u00ab\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c\u00bb<\/p>\n<p>  \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b config.ini \u0440\u0443\u043a\u0430\u043c\u0438 \u0438 \u0436\u043c\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c. <\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043e\u043f\u0438\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 xml \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u0441 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/271483\/\"> http:\/\/habrahabr.ru\/post\/271483\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-268778","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268778"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/268778\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}