c# - Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read -


cannot program read file, not sure i'm doing wrong here, advice welcomed. trying project address book , file contains people's names , addresses , phone numbers.

 public form1()         {             string filename = "addresses.txt";             readfile(filename);             readtokens(filename);         }//end of main          static void readfile(string filename)         {             streamreader readfile;             readfile = file.opentext(filename);             while (!readfile.endofstream)             {                 console.writeline(readfile.readline());             }//end of while             {                 readfile.close();                 console.readkey();             }//end of read file         }         static void readtokens(string filename)         {             streamreader readfile;             string line;             char[] delim = { ',' };             readfile = file.opentext(filename);             while (!readfile.endofstream)             {                 line = readfile.readline(); // reads 1 line @ time                 string[] tokens = line.split(delim);                 foreach (string str in tokens)                 {                     console.writeline(str + "\t\t");                 }//end of each             }             console.readkey();             readfile.close();         }//end of readtokens     }//end of program }//end namespace