using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//msdn中方法
//string path = @"abc.txt";
//try
//{
// using (StreamReader sr = new StreamReader(path))
// {
// while (sr.Peek() >= 0)
// {
// Console.WriteLine(sr.ReadLine());
// }
// Console.Read();
// }
//}
//catch (Exception e)
//{
// Console.WriteLine("The process failed: {0}", e.ToString());
// Console.Read();
{
StreamReader sr = new StreamReader("abc.txt");//此路径需在项目中bin\debug 中
String line="";
while (sr.Peek() >= 0)
{
line = sr.ReadLine();
Console.WriteLine(line);
}
Console.Read();
}
catch (IOException ee)
{
Console.WriteLine(ee.Message);
Console.Read();
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//msdn中方法
//string path = @"abc.txt";
//try
//{
// using (StreamReader sr = new StreamReader(path))
// {
// while (sr.Peek() >= 0)
// {
// Console.WriteLine(sr.ReadLine());
// }
// Console.Read();
// }
//}
//catch (Exception e)
//{
// Console.WriteLine("The process failed: {0}", e.ToString());
// Console.Read();
//}
{
StreamReader sr = new StreamReader("abc.txt");//此路径需在项目中bin\debug 中
String line="";
while (sr.Peek() >= 0)
{
line = sr.ReadLine();
Console.WriteLine(line);
}
Console.Read();
}
catch (IOException ee)
{
Console.WriteLine(ee.Message);
Console.Read();
}
}
}
}