+ 1

How can i read a text from a note pad in c or c#?

11th Sep 2017, 7:38 PM
Mr. Pool
Mr. Pool - avatar
5 Antworten
+ 1
You can read text using the File.ReadAllText() method: public static void Main() { string path = @"c:\oasis\B1.txt"; try { // Open the file to read from. string readText = System.IO.File.ReadAllText(path); Console.WriteLine(readText); } catch (System.IO.FileNotFoundException fnfe) { // Handle file not found. } } string notepad = @"c:\oasis\B1.text"; //this must be Hello world
11th Sep 2017, 8:01 PM
MsJ
MsJ - avatar
0
What do you mean by note pad ? Do you want to read a file ?
11th Sep 2017, 7:41 PM
sneeze
sneeze - avatar
0
Yes...
11th Sep 2017, 7:42 PM
Mr. Pool
Mr. Pool - avatar
0
It is in System.IO string value1 = File.ReadAllText("C:\\file.txt");
11th Sep 2017, 7:47 PM
sneeze
sneeze - avatar
0
Thanks
11th Sep 2017, 7:49 PM
Mr. Pool
Mr. Pool - avatar