So here's the thing,
I have a Textbox with this format:
1,Goku
2,Krillin
3,Friezer
and so on...
and I have an array like this:
array[,] arrDBZ;
I want that for every line in the text file populate my array for example:
arrDBZ would have this values:
arrDBZ[1,Goku]
arrDBZ[2,Krillin]
arrDBZ[3,Friezer]
and so on...
How can i do this?
So far I have this code I found on google:
using (OpenFileDialog fdText=new OpenFileDialog())
{
fdText.Filter="Text Files (*.txt)|*.txt";
fdText.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();
fdText.Multiselect = false;
fdText.Title = "SELECT TEXT FILE";
if (fdText.ShowDialog() == DialogResult.OK)
{
string data = System.IO.File.ReadAllText(fdText.FileName);
string[,] parsedData;
var res = data.Split(',')
.Select(p => Regex.Split(p, "(?<=\\G.{2})"))
.ToArray();
var twoD = new String[res.Length, res[0].Length];
for (int i = 0; i != res.Length; i++)
for (int j = 0; j != res[0].Length; j++)
twoD[i, j] = res[i][j];
txtLoc.Text = fdText.FileName;
parsedData = twoD;
}
But this only populate the second column:
arrDBZ[0,0] would be arrDBZ[null,Goku], arrDBZ[null,Krillin] and so on...
I hope someone can help me with this.
Thanks.