Monday, July 12, 2010

Input & Output's in .Net

FileStream f = File.Create(@"c:\myDataintoFlatFile.dat");
StreamWriter st = new StreamWriter(f);
st.WriteLine("My name is Mahmoud Sayed ahmed");
st.WriteLine("I'm 24 years OLD");
st.WriteLine("I live in CA-USA :)");
st.Flush();
st.Close();


FileStream s = File.Open(@"c:\myDataintoFlatFile.dat", FileMode.Open);
StreamReader read = new StreamReader(s);
while (read.Peek() != -1)
{
string z = read.ReadLine();
if (z.Contains("CA"))
{
Console.WriteLine("CA Found..............");
break;
}
}

No comments:

Post a Comment