读取本地目录的问题, 在windows下,一般会用“”,但在Linux中用的是“/”
Windows和Linux路径分隔符不一样
Windows:
File file1 = new File ("C:demoaa.txt");
Linux:
File file2 = new File ("/demo/aa.txt");
C#开发语言中的路径分隔符为:Path.DirectorySeparatorChar
建议:
string path3 = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar
+ "Temp" +Path.DirectorySeparatorChar
+ "TextFile1.txt";
var text3 = File.ReadAllText(path2);