I need to read the data in the .txt file in the folders from 4 different paths. I've done the code, but it only read the data from the first folder.
How can I read the data in the folder from different paths?
This is my code:
- private void readData()
- {
- string[] Comp = new[] { "A001", "A002", "A003", "A004" };
- string Comps= Comp[0];
- string Path = $@"Z:\IT\Shares\PC\PC-{Comp}\SS\Data\{Comp}_DataFile.txt";
-
-
- var data = File
- .ReadAllLines(Path)
- .Select(x => x.Split('='))
- .Where(x => x.Length > 1)
- .ToDictionary(x => x[0].Trim(), x => x[1]);
- Console.WriteLine("Name: {0}", data["Name"]);
- Console.WriteLine("Age: {0}", data["Age"]);
- }