using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace file
{
class Program
{
static void Main(string[] args)
{
string path = "my_text.txt";
StreamReader r = new StreamReader(path);
string s = r.ReadToEnd();
foreach (var item in s)
{
Console.Write(item);
}
// 2nd Way to read a file
string str ="";
while ((str = r.ReadLine())!=null)
{
Console.WriteLine(str);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace file
{
class Program
{
static void Main(string[] args)
{
string path = "my_text.txt";
StreamReader r = new StreamReader(path);
string s = r.ReadToEnd();
foreach (var item in s)
{
Console.Write(item);
}
// 2nd Way to read a file
string str ="";
while ((str = r.ReadLine())!=null)
{
Console.WriteLine(str);
}
}
}
}
0 comments:
Post a Comment