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


C# System.IO.StreamReader.ReadLine方法代码示例

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


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

示例1: Coordinator

        public Coordinator(MainWindow gameUI)
        {
            this.gameUI = gameUI;

            nickname = "";

            hasGame = false;

            isFreeBuildButtonEnabled = false;

            /*
            //prepare the timer
            timer = new System.Windows.Threading.DispatcherTimer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = new TimeSpan(0, 0, 1);
            */
            // load the card list
            using (System.IO.StreamReader file = new System.IO.StreamReader(System.Reflection.Assembly.Load("GameManager").
                GetManifestResourceStream("GameManager.7 Wonders Card list.csv")))
            {
                // skip the header line
                file.ReadLine();

                String line = file.ReadLine();

                while (line != null && line != String.Empty)
                {
                    fullCardList.Add(new Card(line.Split(',')));
                    line = file.ReadLine();
                }
            }
        }
开发者ID:JamesFairweather,项目名称:7-Wonders-Leaders,代码行数:32,代码来源:Coordinator.cs

示例2: LoadShop

        public static Shop LoadShop(int shopNum)
        {
            Shop shop = new Shop();
            using (System.IO.StreamReader Read = new System.IO.StreamReader(IO.Paths.ShopsFolder + "shop" + shopNum + ".dat")) {
                string[] ShopInfo = Read.ReadLine().Split('|');
                if (ShopInfo[0] != "ShopData" || ShopInfo[1] != "V2") {
                        Read.Close();
                        return null;
                }

                string[] info;
                ShopInfo = Read.ReadLine().Split('|');
                shop.Name = ShopInfo[0];
                shop.JoinSay = ShopInfo[1];
                shop.LeaveSay = ShopInfo[2];
                //shop.FixesItems = ShopInfo[3].ToBool();
                //for (int i = 1; i <= 7; i++) {
                for (int z = 0; z < Constants.MAX_TRADES; z++) {
                    info = Read.ReadLine().Split('|');
                    shop.Items[z].GetItem = info[0].ToInt();
                    //shop.Items[z].GetValue = info[1].ToInt();
                    shop.Items[z].GiveItem = info[1].ToInt();
                    shop.Items[z].GiveValue = info[2].ToInt();
                }
                //}
            }
            return shop;
        }
开发者ID:pzaps,项目名称:Server,代码行数:28,代码来源:ShopManager.cs

示例3: RobotsNetwork

 /// <summary>
 /// Builds network.
 /// </summary>
 /// <param name="path">
 /// Path to file.
 /// </param>
 public RobotsNetwork(string path)
 {
     System.IO.StreamReader file = new System.IO.StreamReader(path);
     this.g = new Graph(file.Read() - 48);
     if (this.g.NumberOfVertex < 1)
         throw new IncorrectInputException();
     this.hereRobot = new bool[this.g.NumberOfVertex];
     file.ReadLine();
     file.ReadLine();
     while (true)
     {
         string[] temp = file.ReadLine().Split(' ');
         if (temp[0][0] == 'R')
             break;
         if (((temp[0][0] - 48) < 0) || ((temp[1][0] - 48) < 0) || ((temp[1][0] - 48) > (this.g.NumberOfVertex - 1)) || ((temp[0][0] - 48) > (this.g.NumberOfVertex - 1)))
             throw new IncorrectInputException();
         g.AddEdge(temp[0][0] - 48, temp[1][0] - 48);
     }
     string[] listRob = file.ReadLine().Split(' ');
     for (int i = 0; i < listRob.Length; ++i)
     {
         if (((listRob[i][0] - 48) < 0 ) || ((listRob[i][0] - 48) > this.g.NumberOfVertex - 1))
             throw new IncorrectInputException();
         this.hereRobot[listRob[i][0] - 48] = true;
     }
     this.classA = new bool[this.g.NumberOfVertex];
     this.classB = new bool[this.g.NumberOfVertex];
     this.visited = new bool[this.g.NumberOfVertex];
     this.Traverse(0, true);
 }
开发者ID:Ershov-Alexander,项目名称:for_study,代码行数:36,代码来源:RobotsNetwork.cs

示例4: re_adress

        public void re_adress()
        {
            try
            {
                name = System.IO.File.ReadAllLines(@"data\adress.txt");
                int x = 0;
                foreach (string l in name)
                {
                    adress[x] = l;
                    x++;
                }

            }
            catch (System.IO.IOException){}

            try
            {
                System.IO.StreamReader file =new System.IO.StreamReader(@"data\name.txt");

                button5.Text = file.ReadLine();
                button6.Text = file.ReadLine();
                button7.Text = file.ReadLine();
                button8.Text = file.ReadLine();
                button9.Text = file.ReadLine();
                button10.Text = file.ReadLine();

                file.Close();
            }
            catch (System.IO.IOException){}
        }
开发者ID:pashkobohdan,项目名称:Browser,代码行数:30,代码来源:Form1.cs

示例5: Template

        /// <summary>
        /// Constructs template form given ABSOLUTE file path.
        /// First line in template is subject. 
        /// Template should look like:
        /// Subject: Hello there
        /// 
        /// Message text goes here
        /// </summary>
        /// <param name="filename">File containing template</param>
        /// <returns></returns>
        public Template(string filename)
        {
            //MailerConfiguration readConfig = (MailerConfiguration)System.Configuration.ConfigurationManager.GetSection("mail");
           
            MailerConfiguration readConfig = ConfigurationHandler.GetSection(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["MailConfig"], "mail");
            FromName = readConfig.SenderName;
            FromEmail = readConfig.SenderEmail;

            try
            {
                System.IO.TextReader fileReader = new System.IO.StreamReader(filename);
                StringBuilder templateBuilder = new StringBuilder("");

                Subject = fileReader.ReadLine();
                Subject.Remove(0, 8);

                string line;
                // Read lines from the file until the end of 
                // the file is reached.
                while ((line = fileReader.ReadLine()) != null)
                {
                    templateBuilder.AppendLine(line);
                }

                this.Body = templateBuilder.ToString();
            }
            catch (System.Exception){}
        }
开发者ID:clpereira2001,项目名称:Lelands-Master,代码行数:38,代码来源:Template.cs

示例6: Main

        static void Main(string[] args)
        {
            string text = System.IO.File.ReadAllText("./readme.txt");
            Console.WriteLine(text);
            Console.ReadLine();

            // don't forget to make readme.txt copy into the output directory!

            System.IO.StreamReader file = new System.IO.StreamReader("./readme.txt");
            string line;

            // fewer lines way
            while ((line = file.ReadLine()) != null)
            {
                Console.WriteLine(line);
            }

            // more understandable what is happening way
            line = file.ReadLine();
            while (line != null)
            {
                Console.WriteLine(line);
            }

            Console.ReadLine();
        }
开发者ID:uugengiven,项目名称:academypgh,代码行数:26,代码来源:Program.cs

示例7: insertCountries

        static void insertCountries()
        {
            MySqlCommand cmd = new MySqlCommand("INSERT INTO `climate`.`countries` (`abbreviation`,`name`) VALUES (@abbrev,@name);", conn);

            conn.Open();
            System.IO.StreamReader countries = new System.IO.StreamReader("Y:\\country-list.txt");
            System.IO.StreamWriter csvCountries = new System.IO.StreamWriter("Y:\\country-list.csv");

            Console.WriteLine(countries.ReadLine());
            Console.WriteLine(countries.ReadLine());

            while (countries.Peek() > 0)
            {
                string line = countries.ReadLine();
                string[] strings = line.Split(new string[] { "          " }, StringSplitOptions.RemoveEmptyEntries);
                //string[] strings = line.Split(new char[] { ' ' }, 12);
                Console.WriteLine(strings[0] + "," + strings[1]);
                csvCountries.WriteLine(strings[0] + "," + strings[1]);
                cmd.Parameters.AddWithValue("abbrev", strings[0]);
                cmd.Parameters.AddWithValue("name", strings[1]);

                cmd.ExecuteScalar();
                cmd.Parameters.Clear();
            }

            conn.Close();
            csvCountries.Close();
            countries.Close();
        }
开发者ID:kip10,项目名称:DataMining,代码行数:29,代码来源:Program.cs

示例8: GetString

 public static string GetString(string fileName, string section, string name, string defaut)
 {
     string line;
     try
     {
         System.IO.StreamReader file = new System.IO.StreamReader(fileName);
         while ((line = file.ReadLine()) != null)
         {
             if (line.TrimStart(' ').StartsWith("[" + section + "]"))
                 break;
         }
         while ((line = file.ReadLine()) != null)
         {
             if (line.TrimStart(' ').StartsWith("["))
                 break;
             if (line.TrimStart(' ').StartsWith(name + "="))
             {
                 int indexEgal = line.IndexOf('=') + 1;
                 return line.Substring(indexEgal , line.Length - indexEgal);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Une exeption a ete detecte : "+e.Message);
     }
     return defaut;
 }
开发者ID:flo3693,项目名称:TPDotNet,代码行数:28,代码来源:ConfigIni.cs

示例9: getMap

        public static Vector2[][] getMap(string mapName, out Vector2 tileSize)
        {
            System.IO.TextReader tr = new System.IO.StreamReader("Content/TopDown/Maps/" + mapName + "/map.txt");
            string tempTileSize = tr.ReadLine();
            string[] tempTileSizes = tempTileSize.Split(',');
            tileSize = new Vector2(float.Parse(tempTileSizes[0]), float.Parse(tempTileSizes[1]));
            string tempMapSize = tr.ReadLine();
            string[] tempMapSizes = tempMapSize.Split(',');
            Vector2 mapSize = new Vector2(float.Parse(tempMapSizes[0]), float.Parse(tempMapSizes[1]));
            string[] mapRows = new string[(int)mapSize.Y];
            Vector2[][] returnMap = new Vector2[(int)mapSize.X][];
            for (int i = 0; i < mapSize.Y; i++)
            {
                mapRows[i] = tr.ReadLine();
            }
            for (int j = 0; j < mapSize.X; j++)
            {
                returnMap[j] = new Vector2[(int)mapSize.Y];
            }

            for (int y = 0; y < mapSize.Y; y++)
            {
                string[] currentRow = mapRows[y].Split(';');
                for (int x = 0; x < mapSize.X; x++)
                {
                    string[] xy = currentRow[x].Split(',');
                    returnMap[x][y] = new Vector2(float.Parse(xy[0]), float.Parse(xy[1]));
                }
            }

            return returnMap;
        }
开发者ID:MinotMakers,项目名称:TheGame,代码行数:32,代码来源:Map.cs

示例10: generateDmcColors

        public void generateDmcColors()
        {
            System.IO.StreamReader inFile = new System.IO.StreamReader(webPageDirectory);
            System.IO.StreamWriter outFile = new System.IO.StreamWriter(dmcDirectory, true);
            string line = "", dmc = "", name = "", color = "";

            while ((line = inFile.ReadLine()) != null)
            {
                if (line.Trim().StartsWith("<TD><FONT face=\"arial, helvetica, sans-serif\" size=2>") && !line.Trim().EndsWith("Select view")) //find dmc
                {
                    dmc = line.Trim().Split(new string[] { "<TD><FONT face=\"arial, helvetica, sans-serif\" size=2>" }, StringSplitOptions.None)[1];
                    dmc = dmc.Split(new string[] { "<" }, StringSplitOptions.None)[0];
                }
                else if (line.Trim().StartsWith("<TD noWrap><FONT face=\"arial, helvetica, sans-serif\" size=2>"))  //find name
                {
                    //issue with line continuation
                    name = line.Trim().Split(new string[] { "<TD noWrap><FONT face=\"arial, helvetica, sans-serif\" size=2>" }, StringSplitOptions.None)[1];
                    name = name.Split(new string[] { "<" }, StringSplitOptions.None)[0];
                    if (!line.Trim().EndsWith("</FONT></TD>"))
                    {
                        line = inFile.ReadLine();
                        name = name + " " + line.Trim().Split(new string[] { "<" }, StringSplitOptions.None)[0];
                    }
                }
                else if (line.Trim().StartsWith("<TD bgColor=") && line.Trim().Contains(">&nbsp;</TD>"))
                {
                    color = line.Trim().Split(new string[] { "<TD bgColor=" }, StringSplitOptions.None)[1];
                    color = color.Split(new string[] { ">" }, StringSplitOptions.None)[0];
                    outFile.WriteLine(dmc + ";" + name + ";" + color);
                }
            }
            inFile.Close();
            outFile.Close();
            Console.ReadLine();
        }
开发者ID:rabidllamaofdoom,项目名称:PixelXStitchy,代码行数:35,代码来源:ColorFinder.cs

示例11: connect

        public static string connect(String server,int port,String ouath)
        {
            System.Net.Sockets.TcpClient sock = new System.Net.Sockets.TcpClient ();
            sock.Connect (server, port);
            if (!sock.Connected) {
                Console.Write ("not working hoe");

            }
            System.IO.TextWriter output;
            System.IO.TextReader input;
            output = new System.IO.StreamWriter (sock.GetStream ());
            input = new System.IO.StreamReader (sock.GetStream ());
            output.Write (

                "PASS " + ouath + "\r\n" +
                "NICK " + "Sail338" + "\r\n" +
                "USER " + "Sail338" + "\r\n" +
                "JOIN " 	+ "#sail338" + "" + "\r\n"

            );
            output.Flush ();

            for (String rep = input.ReadLine ();; rep = input.ReadLine ()) {
                string[] splitted = rep.Split (':');
                if (splitted.Length > 2) {
                    string potentialVote = splitted [2];
                    if (Array.Exists (validVotes, vote => vote.Equals(potentialVote)))
                        return potentialVote;
                }
            }
        }
开发者ID:vanstorm9,项目名称:TwitchCollaborativePartyGame,代码行数:31,代码来源:Program.cs

示例12: readCities

 /// <summary>
 /// Считывает названия городов из файлов карт
 /// <para>Использует пути к файлам из class FilesDirectories</para>
 /// </summary>
 public void readCities(params string[] mapFiles)
 {
     CitiesList = new List<string>();
     for (int i = 0; i < mapFiles.Length; ++i)
     {
         System.IO.StreamReader file = new System.IO.StreamReader(mapFiles[i]);
         string mapType = file.ReadLine().ToLower();
         if (mapType.Contains("воздушная карта"))
         {
             string City;
             //Считывание Аэропортов
             while ((City = file.ReadLine()) != null)
             {
                 string[] RecordParts = City.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                 CitiesList.Add(RecordParts[0]);
             }
             file.Close();
         }
         if (mapType.Contains("наземная карта"))
         {
             string[] GroundCities;
             //Считывание Городов с графовой карты
             GroundCities = file.ReadLine().Split(new char[] { ' ', '\t', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
             file.Close();
             CitiesList.AddRange(GroundCities);
             CitiesList = CitiesList.Distinct<string>().ToList<string>();
         }
     }
     CitiesList.Sort();
 }
开发者ID:Koperfild,项目名称:-------,代码行数:34,代码来源:Cities.cs

示例13: LoadPeople

        // Load people from text file
        public bool LoadPeople()
        {
            TopFivePeople.Clear();
            System.IO.TextReader TextIn = null;
            try
            {
                TextIn = new System.IO.StreamReader(filename);

                int NumberOfPerson = int.Parse(TextIn.ReadLine());
                for (int i = 0; i < NumberOfPerson; i++) // Load all the high score people
                {
                    string PersonName = TextIn.ReadLine();
                    int Score = int.Parse(TextIn.ReadLine());
                    TopFivePeople.Add(new PersonDetails(PersonName, Score));
                }

            }
            catch
            {
                return false;
            }
            finally
            {
                if (TextIn != null) TextIn.Close();
            }
            return true;
        }
开发者ID:ADWilsonCode,项目名称:Full-Fruity-Squash,代码行数:28,代码来源:HighScore.cs

示例14: Hours

        public void Hours()
        {

            System.IO.StreamReader sr = new System.IO.StreamReader("TestWAG.txt");
            sr.ReadLine();
            sr.ReadLine();

            BarListImpl bl = new BarListImpl(BarInterval.Hour, "WAG");
            Tick k = new TickImpl();
            int tickcount = 0;
            while (!sr.EndOfStream) 
            {
                k = eSigTick.FromStream(bl.Symbol, sr);
                if (tickcount == 0)
                {
                    Assert.IsTrue(k.isValid);
                    Assert.AreEqual(20070926041502, k.datetime);
                    Assert.AreEqual(20070926, k.date);
                    Assert.AreEqual(041502, k.time);
                    Assert.AreEqual(43.81m, k.bid);
                    Assert.AreEqual(51.2m, k.ask);
                    Assert.AreEqual(1, k.bs);
                    Assert.AreEqual(1, k.os);
                    Assert.IsTrue(k.be.Contains("PSE"));
                    Assert.IsTrue(k.oe.Contains("PSE"));
                }
                tickcount++;
                bl.newTick(k);
            }
            // hour is what we asked for
            Assert.AreEqual(BarInterval.Hour,bl.DefaultInterval);
            // there are 4 trades on hour intervals, 6/7/8/9
            Assert.AreEqual(4,bl.Count);

        }
开发者ID:antonywu,项目名称:tradelink,代码行数:35,代码来源:TesteSigTick.cs

示例15: Main

 static void Main(string[] args)
 {
     System.IO.StreamReader sr = new System.IO.StreamReader("D:/tmp/laba10.txt");
     string line = sr.ReadLine();
     int size = int.Parse(line);
     graph = new int[size, size];
     path = new int[size];
     mpath = new int[size];
     line = sr.ReadLine();
     pointA = int.Parse(line)-1;
     line = sr.ReadLine();
     pointB = int.Parse(line)-1;
     while (!sr.EndOfStream)
     {
         line = sr.ReadLine();
         string[] spl = line.Split(new char[] { ',' });
         int i = int.Parse(spl[0]);
         int j = int.Parse(spl[1]);
         int c = int.Parse(spl[2]);
         graph[i-1,j-1] = c;
     }
     search(pointA);
     Console.WriteLine("Path:");
     for (int i = 0; i < size && mpath[i]>0; i++)
     {
         Console.Write(mpath[i] + ", ");
     }
     Console.ReadLine();
 }
开发者ID:aleksey-zhidkov,项目名称:School-stuff,代码行数:29,代码来源:Program.cs


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