[Solved] C# Readint a txt file and creating an exact copy of it inside a program


To acomplish your goal you need to do two steps:

  1. Read the entire file.
  2. Transform to appropiate structure.

Thanks to LINQ you can accomplish quickly:

var cells = (from l in System.IO.File.ReadAllLines("myfile.txt")
                    select l.Split(" ".ToArray(), StringSplitOptions.RemoveEmptyEntries)).ToArray();

Now you can access the cells like this:

var value = cells[1][2];

3

solved C# Readint a txt file and creating an exact copy of it inside a program