1
Answer

Simple TextRead program not working

Jeffrey Webster

Jeffrey Webster

15y
3.7k
1
Hi,
I'm currently making the transition from VB to C# and seem to by having some trouble with the syntax.

Here's the code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TextReaderConsole1
{
    class Program
    {
        static void Main(string[] args)
        {
           
            TextReader reader = new StreamReader("c:\textdocs\text.txt");
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                Console.WriteLine(line);
            }
            reader.Close();
        }
    }
}

It keeps giving me an "Illegal characters" message. But I don't see any illegal characters. I've tried changing everything to lowercase, including the folder and file it's referencing. The compiler is still complaining.

Any help would be appreciated.

Jeff


Answers (1)