使用此代码遇到一些问题

Getting stuck with a few things with this code

您好。我是编码新手,所以我面临的这些问题对你们中的一些人来说可能很容易。我正在尝试制作一个简单的工具来获取导出的文件并读取文件中的价格数据。但首先我需要能够导入当前位于 \Marketlogs 中的文件。所有文件都是 .txt。我已经得到它来处理一个集合名称,但我还没有找到导入未知名称的方法。这是它可能提取的文件名的示例 "Esoteria-Liquid Ozone-2019.05.04 015804"

我一直在关注 IAmTimCorey youtube 视频以了解如何读取文件的基本概念,但他的视频使用的是固定文件名

https://www.youtube.com/watch?v=cST5TT3OFyg&list=PLsBhi5lzz1f2-AbhurnGazN68UgG4dVwt&index=1

https://www.youtube.com/watch?v=yClSNQdVD7g&list=PLsBhi5lzz1f2-AbhurnGazN68UgG4dVwt&index=2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows;


namespace Eve_market
{
    class Program
    {
        static void Main(string[] args)
        {
            /// MarketLog
            // opens a file from MarketLogs 
         ```   string filePath = @"E:\Users\Hamilton Norris\Documents\EVE\logs\Marketlogs\"; ```
            // converts file to a  readable csv from text with filteable deta
            List<MarketLog> log = new List<MarketLog>();

            List<string> lines = File.ReadAllLines(filePath).ToList();

            foreach (string line in lines)
            {
                string[] enteries = line.Split(',');

                MarketLog newMarketLog = new MarketLog();

                newMarketLog.Price = enteries[0];
                newMarketLog.VolReamining = enteries[1];
                newMarketLog.TypeID = enteries[2];
                newMarketLog.Range = enteries[3];
                newMarketLog.OrderID = enteries[4];
                newMarketLog.VolEntered = enteries[5];
                newMarketLog.MinVolume = enteries[6];
                newMarketLog.Bid = enteries[7]; // False = sell order  true = buy order
                newMarketLog.IssueDate = enteries[8];
                newMarketLog.Bidurationd = enteries[9];
                newMarketLog.StationID = enteries[10];
                newMarketLog.RegionID = enteries[11];
                newMarketLog.SolarSystemID = enteries[12];
                newMarketLog.Jumps = enteries[13]; //  0 = same system

                log.Add(newMarketLog);
            }

            foreach (var MarketLog in log)
            {
                Console.WriteLine($"{ MarketLog.Price } {MarketLog.VolReamining } {MarketLog.Bid} ");

            }


            // MarketLog End

            Console.ReadLine();
        }


    }
}

请尝试以下代码:(获取目录,然后获取具有匹配文件模式的文件。然后一个一个地加载并像往常一样使用您的代码读取文件)

 var fileNamePattern = "*.txt";
 var dir = new DirectoryInfo(path);
 IEnumerable<FileSystemInfo> files = dir.GetFileSystemInfos(fileNamePattern);
 files
    .ToList()
    .ForEach(f=>        
    {
       //Load each file using File system Info:
       List<string> lines = File.ReadAllLines(f.FullName).ToList();
       //............
    });