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


C# FileIniDataParser.ReadFile方法代码示例

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


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

示例1: check_parses_real_test_files

        public void check_parses_real_test_files()
        {
            var parser = new FileIniDataParser();
            parser.Parser.Configuration.ThrowExceptionsOnError = true;

            var iniFileData = parser.ReadFile("aircraft.cfg");

            parser.Parser.Configuration.CommentString = "//";
            iniFileData = parser.ReadFile("aircraft2.cfg");
        }
开发者ID:rickyah,项目名称:ini-parser,代码行数:10,代码来源:FileIniDataParserTests.cs

示例2: 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

示例3: Load

        public static void Load()
        {
            List.Clear();

            foreach (var item in Directory.GetFiles(Global.Folder.Profile, "*.ifp"))
            {
                var parser = new FileIniDataParser();
                IniData data = parser.ReadFile(item);

                var p = new Profile();

                p.File = item;
                p.Info.Format = data["info"]["format"];
                p.Info.Platform = data["info"]["platform"];
                p.Info.Name = data["info"]["name"];
                p.Info.Author = data["info"]["author"];
                p.Info.Web = data["info"]["web"];
                p.Picture.Resolution = data["picture"]["resolution"];
                p.Picture.FrameRate = data["picture"]["framerate"];
                p.Picture.BitDepth = Convert.ToInt32(data["picture"]["bitdepth"]);
                p.Picture.Chroma = Convert.ToInt32(data["picture"]["chroma"]);
                p.Video.Preset = data["video"]["preset"];
                p.Video.Tune = data["video"]["tune"];
                p.Video.Type = Convert.ToInt32(data["video"]["type"]);
                p.Video.Value = data["video"]["value"];
                p.Video.Command = data["video"]["cmd"];
                p.Audio.Encoder = data["audio"]["encoder"];
                p.Audio.BitRate = data["audio"]["bitrate"];
                p.Audio.Freq = data["audio"]["frequency"];
                p.Audio.Chan = data["audio"]["channel"];
                p.Audio.Args = data["audio"]["cmd"];

                List.Add(p);
            }
        }
开发者ID:zeruel11,项目名称:IFME,代码行数:35,代码来源:Profile.cs

示例4: GetConnectionString

        public static String GetConnectionString(String AppID)
        {
            FileIniDataParser i = new FileIniDataParser();

            i.Parser.Configuration.CommentString = "#";

            IniData data = i.ReadFile(Settings.Preferences.GetConfig());

            bool decrypt = false;

            if (Convert.ToBoolean(data["HOST"]["Encrypt"]))
            {
                decrypt = true;
            }

            String myConnectionString = "";

            if (decrypt)
            {
                myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};",
                    data["HOST"]["IP"], data["HOST"]["User"], MySQLSet.Decrypt(data["HOST"]["Pass"]), data["HOST"]["Port"], data["DS"][AppID]);
            }
            else
            {
                myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};",
                    data["HOST"]["IP"], data["HOST"]["User"], data["HOST"]["Pass"], data["HOST"]["Port"], data["DS"][AppID]);
            }

            return myConnectionString;
        }
开发者ID:NiDragon,项目名称:IllTechLibrary,代码行数:30,代码来源:IllSQL.cs

示例5: IsTroopsReady

 public static bool IsTroopsReady()
 {
     FileIniDataParser parser = new FileIniDataParser();
     IniData data = parser.ReadFile("config.ini");
     string stringPosition = data["barracks"]["barrack1"];
     Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1]));
     if (pointPosition.X != -1 || pointPosition.Y != -1)
     {
         Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false);
         Thread.Sleep(500);
         if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176)))
             Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false);
         else
             Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false);
         Thread.Sleep(500);
         if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("troop_ready", Settings.xDif, Settings.yDif)), Color.FromArgb(216, 72, 81)))
         {
             Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
             Thread.Sleep(500);
             Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
             return true;
         }
     }
     Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
     Thread.Sleep(500);
     Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
     return false;
 }
开发者ID:Jeremymav,项目名称:ClashofBots,代码行数:28,代码来源:TrainTroops.cs

示例6: Train

        public static void Train()
        {
            FileIniDataParser parser = new FileIniDataParser();
            IniData data = parser.ReadFile("config.ini");
            for (int i = 1; i <= 4; i++)
            {
                string stringPosition = data["barracks"]["barrack" + i];
                Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1]));
                string stringTroop = data["troops"]["barrack" + i];
                int intTroop = Convert.ToInt32(stringTroop);
                if(pointPosition.X != -1 || pointPosition.Y != -1)
                {
                    Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false);
                    Thread.Sleep(1000);
                    if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176)))
                        Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false);
                    else if(ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("3_3", Settings.xDif, Settings.yDif)), Color.FromArgb(161, 184, 207)))
                        Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("3_3", Settings.xDif, Settings.yDif), false);
                    else
                        Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false);

                    Thread.Sleep(1000);
                    while (!SameRGB(Home.bsProcess.image.GetPixelColor(CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif))))
                    {
                        Home.bsProcess.mouse.SendClick(WButton.Left, CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif), false);
                        Thread.Sleep(100);
                    }
                    Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0,0), false);
                    Thread.Sleep(500);
                }
            }
            Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
        }
开发者ID:Jeremymav,项目名称:ClashofBots,代码行数:33,代码来源:TrainTroops.cs

示例7: programLoad

        public void programLoad()
        {
            { //load from config file
                FileIniDataParser parser = new FileIniDataParser();
                IniData data = parser.ReadFile("resource/installer.ini");
                {// set logo image
                    var logoPath = data["GLOBAL"]["logo"];
                    string logoClean = String.Format("resource/{0}", logoPath);
                    Console.WriteLine("ini file claims logo image is {0}", logoClean);

                    FileInfo fi = new FileInfo(logoClean);
                    long logoSize = (fi.Length / 1024);
                    Console.WriteLine("Loaded logo ({0}KB)", logoSize);
                    this.logo.ImageLocation = logoClean;
                    fi = null; //destroy FileInfo
                }
                {//figure out what to install
                    var toInstall = data["GLOBAL"]["file"];
                    var where = data["GLOBAL"]["destination"];
                    Console.WriteLine("ini file claims {0} is going to be installed to {1}", toInstall, where);
                }
                {//set readme docs
                    this.readmedocs = new Uri(data["GLOBAL"]["readme"], UriKind.Absolute);
                    Console.WriteLine("ini file claims readme docs are located {0}", this.readmedocs);
                }
                {//set start page text
                    this.startText = data["GLOBAL"]["startpage"].Replace("{break}",Environment.NewLine);
                    Console.WriteLine("loaded start text from ini file");
                }
            }
        }
开发者ID:teh-random-name,项目名称:SCInstaller,代码行数:31,代码来源:bacpro.cs

示例8: WakaTimeConfigFile

 /// <summary>
 /// Initializes a new instance of the <see cref="MonoDevelop.WakaTime.WakaTimeConfigFile"/> class.
 /// </summary>
 static WakaTimeConfigFile()
 {
     _configParser = new FileIniDataParser();
     _configFilepath = GetConfigFilePath();
     _configData = (File.Exists(_configFilepath))
         ? _configParser.ReadFile(_configFilepath, new UTF8Encoding(false))
         : new IniData();
     Read();
 }
开发者ID:solrevdev,项目名称:monodevelop-wakatime,代码行数:12,代码来源:WakaTimeConfigFile.cs

示例9: 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

示例10: GetData

        public static IniData GetData()
        {
            FileIniDataParser i = new FileIniDataParser();

            i.Parser.Configuration.CommentString = "#";

            IniData data = i.ReadFile(GetConfig());

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

示例11: check_parse_unicode_chinese_characters

        public void check_parse_unicode_chinese_characters()
        {
            var parser = new FileIniDataParser();
            parser.Parser.Configuration.ThrowExceptionsOnError = true;

            var iniFileData = parser.ReadFile("unicode_chinese.ini");

            // If you want to write the file you must specify the encoding
            //parser.WriteFile("unicode_chinese_copy.ini", iniFileData, Encoding.UTF8);
        }
开发者ID:rickyah,项目名称:ini-parser,代码行数:10,代码来源:FileIniDataParserTests.cs

示例12: 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

示例13: test_multiple_file_encodings

        public void test_multiple_file_encodings()
        {
            var parser = new FileIniDataParser();

            // Encoding.Default is now the default value used in the ReadFile method, but is
            // specified in this call for consistency with the issue report
            IniData parsedData = parser.ReadFile("./Issue18_example.ini", Encoding.UTF8);

            Assert.That(parsedData.Sections.ContainsSection("Identität"));
            Assert.That(parsedData.Sections["Identität"]["key"], Is.EqualTo("value"));
        }
开发者ID:rickyah,项目名称:ini-parser,代码行数:11,代码来源:FileIniDataParserTests.cs

示例14: Settings

        public Settings()
        {
            var settingsFile = Path.Combine(BasePath, "config.ini");
            if (!File.Exists(settingsFile))
            {
                Logger.Log(String.Format("Settings file {0} does not exist. Creating default file.", settingsFile), Logger.LogType.Warn, typeof(Settings));
                using (File.Create(settingsFile)) { }
            }
            Logger.Log(String.Format("Loading settings from {0}", settingsFile), typeof(Settings));

            _parser = new FileIniDataParser();
            _ini = _parser.ReadFile(settingsFile);
            LoadSettings();
        }
开发者ID:Itsyuka,项目名称:A3-Memcache-Extension-CSharp,代码行数:14,代码来源:Settings.cs

示例15: IniFile

        private IniFile()
        {
            Data = new IniData();

            // If ini file is not present, then just exit.
            if (!System.IO.File.Exists(IniFile.IniFileName))
            {
                return;
            }

            // Else parse the data.
            var iniParser = new FileIniDataParser();
            Data = iniParser.ReadFile(IniFileName);
        }
开发者ID:zoharmodifier,项目名称:SkillKeeper,代码行数:14,代码来源:IniFile.cs


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