首页 > Windows开发 > 详细

修改eado.ini文件C#

时间:2020-09-03 21:00:44      阅读:59      评论:0      收藏:0      [点我收藏+]

文件内容

[DEFAULT]
NICKNAME=Mu3Seagate
FIRSTNAME=wang
LASTNAME=123456
SINGILECONNECTION=1


[HP]
NICKNAME=HP
FIRSTNAME= 123456
LASTNAME= 52631
SINGILECONNECTION=1

[RMA189]
NICKNAME=RMA
FIRSTNAME=5891
LASTNAME=5555555
SINGILECONNECTION=1

 

  List<string> list = new List<string>();
            list = File.ReadAllLines(@"C:\Windows\Eado.ini").ToList().Where(x => !string.IsNullOrEmpty(x)).ToList();
            List<string> listdns = new List<string>(); //0,5,10
            List<string> listNICKNAME = new List<string>(); //1,6,11
            List<string> listFIRSTNAME = new List<string>();  //2,7,12
            List<string> listLASTNAME = new List<string>();   //3,8,13
            List<string> listSINGILECONNECTION = new List<string>(); //4,9,14 
            for (int i = 0; i < list.Count; i++)//等差数列算法
            {
                if (i % 5 == 0) listdns.Add(list[i].Replace("[","").Replace("]","").Trim());
                else if (i % 5 == 1) listNICKNAME.Add(list[i].Replace("NICKNAME", "").Replace("=", "").Trim());
                else if (i  % 5 == 2) listFIRSTNAME.Add(list[i].Replace("FIRSTNAME", "").Replace("=", "").Trim());
                else if (i  % 5 == 3) listLASTNAME.Add(list[i].Replace("LASTNAME", "").Replace("=", "").Trim());
                else if (i % 5 == 4) listSINGILECONNECTION.Add(list[i].Replace("SINGILECONNECTION", "").Replace("=", "").Trim());
            }
            List<FileModel> listFile = new List<FileModel>();
            for (int i = 0; i < listdns.Count; i++)
            {
                listFile.Add(new FileModel() {
                    dns = listdns[i],NICKNAME =listNICKNAME[i],FIRSTNAME=listNICKNAME[i], LASTNAME=listLASTNAME[i],
                    SINGILECONNECTION =listSINGILECONNECTION[i] });
            }
            return listFile.Where(x => x.dns.ToUpper().Equals("DEFAULT")).ToList().FirstOrDefault().NICKNAME;

 

修改eado.ini文件C#

原文:https://www.cnblogs.com/wangjp-1233/p/13609309.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!