怎樣查網(wǎng)站用什么程序做的今天頭條新聞100條
?引用:System.IO;
Path.Combine();? //將字符串組合成一個路徑
Path.GetFullPath(); //返回指定路徑的絕對路徑
File.ReadAllLines(); //讀取文本框返回一個數(shù)組
File.ReadAllText();? //讀取文本框返回一個字符串
File.ReadAllBytes();? //讀取文本框返回字節(jié)
class Program{static void Main(string[] args){//string filePath = @"?D:t_sql.txt"; //如果直接拼接可能會報錯:不支持給定的路徑string str = Path.Combine(@"D:", "t_sql.txt");string str1 = Path.GetFullPath(str);try{//讀取文本所有行,然后關(guān)閉 結(jié)果:以文本的行為單位返回數(shù)組string[] content = File.ReadAllLines(str);Console.WriteLine(content);//讀取文本所有行,然后關(guān)閉 結(jié)果:以整個文本為單位返回字符串string content1 = File.ReadAllText(str);Console.WriteLine(content1);}catch (IOException e){Console.WriteLine("An IO exception has been thrown!");Console.WriteLine(e.ToString());}Console.ReadKey();}}