private void abrirLabirintoToolStripMenuItem_Click(object sender,
EventArgs e)
{
OpenFileDialog Abrir = new OpenFileDialog();
Abrir.ShowDialog();
string CarregaArq = null;
string teste = null; //string auxiliar
StreamReader LeituraDoArq = new StreamReader(Abrir.FileName);
while (!LeituraDoArq.EndOfStream)
{
CarregaArq = LeituraDoArq.ReadToEnd();
teste = CarregaArq;
richtxtLabirinto.Text = teste;
}
var mt = richtxtLabirinto.Text.Split('\n');
var mt2 = mt[0].Length; //colunas da matriz
var mt3 = mt.Count(); //linhas da matriz
int I = 0, J = 0;
char[,] ArrChar = new char[mt2, mt3];
richtxtLabirinto.Text = string.Empty;
int a = teste.Length;
int b = 0;
using (StringReader LendoStr = new StringReader(teste))
{
for (I = 0; I < mt2; I++)
{
for (J = 0; J < mt3; J++)
{
if (b < a)
{
ArrChar[I, J] = teste[b];
b++;
}
}
}
}
for (I = 0; I < mt2; I++)
{
for (J = 0; J < mt3; J++)
{
richtxtLabirinto.Text = richtxtLabirinto.Text +
Convert.ToString(ArrChar[I, J]);
}
}
The array gets too many lines, why? Below I'm putting an image of the .txt file
Resultofwhatyouaregivingthiscode