System io,console application
System IO - Mobile Info
Amy is a data entry operator in a mobile company; she needs to store some information about the mobiles in a file name MobileInfo.txt. If the file exists, the new content must be appended to its end. How can you help her to perform this task using a console application?
Sample Input/Output Statements:
Enter a Sentence(or Press enter key to stop reading) :
Micormax becomes 10th Largest Mobile Phone Brand world wide
Enter a Sentence(or Press enter key to stop reading) :
Samsung Galaxy S6 sales off to a better start than Galaxy S5
Enter a Sentence(or Press enter key to stop reading) :
Mobile Information stored successfully
--------------------
Here is my code which is givinh runtime error
//codeusing System;
using System.IO;
namespace csharp_station.howto
{
class TextFileWriter
{
static void Main(string[] args)
{
// create a writer and open the file
//TextWriter tw = new StreamWriter("date.txt");
// write a line of text to the file
System.IO.StreamWriter tw =
new System.IO.StreamWriter("MobileInfo.txt", true);
Console.WriteLine("Enter a Sentence(or Press enter key to stop reading) :");
Console.ReadLine();
tw.WriteLine("Micormax becomes 10th Largest Mobile Phone Brand world wide ");
///Console.WriteLine("Enter a Sentence(or Press enter key to stop reading) :");
//Console.ReadLine();
tw.WriteLine("Enter a Sentence(or Press enter key to stop reading) :");
tw.WriteLine("Samsung Galaxy S6 sales off to a better start than Galaxy S5 ");
//Console.WriteLine("Enter a Sentence(or Press enter key to stop reading) :");
// Console.ReadLine();
tw.WriteLine("Enter a Sentence(or Press enter key to stop reading) :");
tw.WriteLine("Mobile Information stored successfully");
// close the stream
tw.Close();
}
}
}