read line by line the text file for make map in xna
- by Mohammadali Najjar khodabakhsh
i want to read a text file for build map; for example I have this map
0@0000000
0@0000000
0@0000000
000000000
000000000
000000000
000000000
I know I should use this :
StreamReader reader = new StreamReader(Application.StartupPath+@"/TestMap.MMAP");
string line = reader.ReadToEnd();
reader.Close();
now for example I want read line 2 char "@". how can i do this?
please help me.
solve :
Thank you (L.B AND user861114)
at last my problem solve like this :
string[,] item = new string[9, 7];
string[] line = File.ReadAllLines(Application.StartupPath + @"/TestMap.MMAP");
for (int j = 0; j < 7; j++)
{
for (int i = 0; i < 9; i++)
{
item[i, j] = line[j].Substring(i, 1);
Console.WriteLine(i + " " + j + "=" + item[i, j]);
}
}
thanks alot.