C#读取文本数据(按行读取)

            StreamReader sr = new StreamReader(path, Encoding.Default);  //path为文件路径
            String line;
            while ((line = sr.ReadLine()) != null)//按行读取 line为每行的数据
            {
                if (line.Contains("GPGGA") || line.Contains("GPVTG"))
                {
                    sw.WriteLine(line); //写入--
                }
            }

 

你可能感兴趣的:(C#)