C# -

12:09:2013 г.

C#. , , , , C# ( WindowsForms WPF). - .

"" . , , ini . ini C# - , , . , - - , , , , .

classINI
{
     publicstring path;

    [DllImport("kernel32")]
    private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
    [DllImport("kernel32")]
    private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

    public INI(string INIPath)
    {
         path = INIPath;
    }

    public void IniWriteValue(string Section, string Key, string Value)
    {
           if(!Directory.Exists(Path.GetDirectoryName(path)))
                 Directory.CreateDirectory(Path.GetDirectoryName(path));
           if(!File.Exists(path))
                  using (File.Create(path)) { };

           WritePrivateProfileString(Section, Key, Value, this.path);
    }

   public string IniReadValue(string Section, string Key)
   {
         StringBuilder temp = new StringBuilder(255);
         int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
         return temp.ToString();
   }
}

, , , C# ini . , ( , - ini-) .

. :

INI ini = new INI("__"); ini.IniWriteValue("Test_block","Key","Value");

Key, Value. :

string value = ini.IniReadValue("Test_block","Key");

 

  

 
+3#1MrOcelot2014-08-31 11:58StringBuilder System.Text
, .
 





« Tinymce ASP.NET MVC 4 -   C# Windows Forms - 3 »

fotic.jpg