Advertisement
amironov73

Загрузка INI-файла

Jan 17th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2.  
  3. using ManagedClient;
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         const string CS = "host=127.0.0.1;user=1;password=1;";
  10.  
  11.         using (ManagedClient64 client = new ManagedClient64())
  12.         {
  13.             client.ParseConnectionString(CS);
  14.             client.Connect();
  15.  
  16.             string fileName = client.Database + ".ini";
  17.             // string fileName = "NoSuchFile" + ".ini";
  18.  
  19.             string text = client.ReadTextFile
  20.                 (
  21.                     IrbisPath.MasterFile,
  22.                     fileName
  23.                 );
  24.  
  25.             if (string.IsNullOrEmpty(text))
  26.             {
  27.                 Console.WriteLine("Тут ничего нет, расходимся!");
  28.             }
  29.             else
  30.             {
  31.                 IniFile iniFile = IniFile.ParseText<IniFile>(text);
  32.  
  33.                 string itemNumb = iniFile.GetString
  34.                     (
  35.                         "Search",
  36.                         "ItemNumb",
  37.                         "0"
  38.                     );
  39.  
  40.                 Console.WriteLine(itemNumb);
  41.  
  42.             }
  43.         }
  44.  
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement