示例#1
0
        static List<VideoCard> readFile(String filename)
        {
            string text = System.IO.File.ReadAllText(filename);
            System.Console.WriteLine("Contents of radeonCards.csv = {0}", text);

            string[] lines = System.IO.File.ReadAllLines(filename);
            System.Console.WriteLine("Contents of WriteLines2.txt");
            List<VideoCard> cardList = new List<VideoCard>();
            for(int i=0; i<lines.Length; i++)
            {
                string line = lines[i];
                VideoCard video = new VideoCard();
                Console.WriteLine("\t" + line);

                if (line.Contains('"'))
                {
                    List<string> quotes = line.Split('"').ToList<string>();
                    List<string> parsedInfo = quotes[2].Split(',').ToList<string>();
                    video.SetCardName(quotes[1]);
                    video.SetHashRate(Convert.ToInt32(parsedInfo[1]));
                }
                else
                {
                    List<string> parsedInfo = line.Split(',').ToList<string>();
                    video.SetCardName(parsedInfo[0]);
                    video.SetHashRate(Convert.ToInt32(parsedInfo[1]));
                }

                video.SetId(i);
                cardList.Add(video);
            }
            return cardList;
        }