Justin N

Justin N

  • NA
  • 19
  • 0

Need help with IOException

Jan 10 2010 4:26 AM
how do i stop this from throwing an IOException?
namespace BrowseFileSystem
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);            
            sw.Write(input);
            ms.WriteTo(File.Create(@"f:\textfile2.txt"));
            sw.Close();
            ms.Close();
            
            //while (true)
            //{
            //    try
            //    {
            StreamReader sr = new StreamReader(@"f:\textfile2.txt");
            Console.WriteLine(sr.ReadToEnd());
            //    }
            //    catch (Exception) { }
            //}
        }
    }
}

Answers (4)