我的解决方案资源管理器中有一个CSV文件:
如何在Solution Explorer中传递文件路径?
码:
String filepath="C:\\Users\\vikas\\Desktop\\fetching.csv";
DataTable dt = new DataTable();
string[] lines = System.IO.File.ReadAllLines(filepath);
代替解决方案资源管理器路径中的文件路径传递文件。
让我们假设您在TestFolder目录中有一个名为test.txt的文件
你可以像这样访问它:
string filePath = AppDomain.CurrentDomain.BaseDirectory + @"\TestFolder\test.txt";
string[] lines = System.IO.File.ReadAllLines(filepath);