Example #1
0
        public void Save(string fileName, IDesign filable)
        {
            List <string> theGrid = new List <string>();
            int           rows    = filable.GetRowCount();
            int           cols    = filable.GetColumnCount();
            StringBuilder sb      = new StringBuilder();

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    sb.Append((char)filable.WhatsAt(r, c));
                }
                sb.Append(',');
            }
            sb.Remove(sb.Length - 1, 1); //remove the last ,

            string compressed = Convert.Compress(sb.ToString());

            string[] fileLines = { "<" + FileManager.STATS + "></" + FileManager.STATS + ">",
                                   "<" + FileManager.GRID + ">" + compressed + "</" + FileManager.GRID + ">" };
            File.WriteAllLines(DIR + fileName + EXTENSION, fileLines);
        }