检查空白csv文件、循环查询、,

检查空白csv文件、循环查询、,,csv,null,Csv,Null,我正试图阻止在我的简单采样程序中导致错误的空csv文件,只需从文件夹中的每个.csv文件中获取2个值 我有空检查,它现在捕捉到了它,但我不确定如何重新构造我的代码,以便它将数组中的文件跳过到下一个,非常欢迎任何帮助 foreach (string name in array1) { // sampling engine loop here, take first line only, first column DateTimeStamp and second is

我正试图阻止在我的简单采样程序中导致错误的空csv文件,只需从文件夹中的每个.csv文件中获取2个值

我有空检查,它现在捕捉到了它,但我不确定如何重新构造我的代码,以便它将数组中的文件跳过到下一个,非常欢迎任何帮助

    foreach (string name in array1)
    {
        // sampling engine loop here, take first line only, first column DateTimeStamp and second is Voltage
        Console.Write("\r      Number of File currently being processed = {0,6}", i);
        i++;
        var reader = new StreamReader(File.OpenRead(name)); // Static for testing only, to be replaced by file filter code

        var line = reader.ReadLine();
        if (line == null)
        {
            Console.WriteLine("Null value detected");
            Console.ReadKey();
            break;
        }
        var values = line.Split(',');

                     reader.ReadLine();
            if (values.Length == 89)
            {
                using (StreamWriter outfile = new StreamWriter(@"C:\\SampledFileResults.txt", true))
                {
                    string content = "";
                    {
                        content = content + values[0] + ",";
                        content = content + values[9] + ",";
                    }
                    outfile.WriteLine(content);
                    Console.WriteLine(content);
                }
            }                
    }
Console.WriteLine("SAMPLING COMPLETED");

只是继续使用;关键词类似于break;但是跳过枚举中的下一个项目,它起到了作用,但是为什么我的代码输出文件中的所有行,我只需要第1行,然后打开下一个文件,仅第1行,下一个文件,直到结束,我做错了什么,现在排序,非常感谢,StevieB