路径设置为C:\Users\lijunliang\source\repos\ConsoleApp12\ConsoleApp12\bin\Debug\netcoreapp3.1\worklist.csv 用filestream打开的时候不能识别,filestream总是认为是相对路径将“C:\Users\lijunliang\source\repos\ConsoleApp12\ConsoleApp12\bin\Debug\netcoreapp3.1\”补上导致抛出异常
class Program
{
static void Main(string[] args)
{
//LisSystemApplication.Current.Prepare();
bool result = true;
string lisFilePath = @"C:\Users\lijunliang\source\repos\ConsoleApp12\ConsoleApp12\bin\Debug\netcoreapp3.1\worklist.csv";
List<List<string>> lisContests = CSVFileHelper.LoadCSVFile(lisFilePath);
Console.WriteLine(result);
}
}
internal class CSVFileHelper
{
internal static List<List<string>> LoadCSVFile(string lisFilePath)
{
List<List<string>> samples = new List<List<string>>();
using (FileStream stream = new FileStream(lisFilePath,FileMode.Open,FileAccess.ReadWrite))
{
using (StreamReader sr = new StreamReader(stream, Encoding.UTF8))
{
while (sr.Peek() >= 0)
{
string[] recordResult = sr.ReadLine().Split(new char[] { ',' });
List<string> recordList = new List<string>();
recordList.AddRange(recordResult);
samples.Add(recordList);
}
}
}
return samples;
}
}