0
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 matrix gets extra lines, why? Below I am placing an image of the file . txt
Result of what is giving this code
is wearing a
RichTextBox
?– Rovann Linhalis
Yeah, but relax, I got it fixed, thanks
– Braian Freitas
@Braianfreitas, Include your answer and mark as accepted then.
– Leandro Angelo