5
Answers

Solved:Problem writing to a file

Michael Cline

Michael Cline

13y
12.7k
1
Wow it's been a while since I've been on these forums, a lot has changed. Looks good, :)

I have a rather strange problem, for the life of me I can't figure out what I did wrong, but here goes. 

I have an array of map tile information such as mapTile[i,n] really they're just strings containing the sprite sheet, and position of the tile that should be displayed. the strings are relatively small, maybe 7 chars long. 

when I create a blank map, i write the first line containing the maps name, height and width, and the event file associated with the map. 

then I loop through the tiles writing each on its own line, the problem is it cuts off at the same place each time, I'm not sure if there is a maximum number of lines etc, but I see no problem with my code. and it cuts off in the middle of a string. anyway heres my code:

 public void CreateNewMap(string Filename, int width, int height)
        {
            TextWriter tw = new StreamWriter(Filename + ".dat");
            string firstline = Filename + "#" + width + "#"+ height +"#72" ;//Map Information line
            tw.WriteLine(firstline);
            for(int i = 0; i < height;i++)  //Set Every tile to empty. . . 
            {                
                for (int n = 0; n < width; n++)
                {
                    tw.WriteLine("0;0;0#0");
                }                
            }
        }

Any help would be greatly appreciated.

 I've been testing with a 100x100 map size. it cuts off at line 9898 and on that line only the first 4 char's are written. 
Answers (5)