编辑: map[][] 充满了按钮
主要问题是 .image 似乎无法保存。我想做一个加载,当我在每个地图[i][j]中加载它时,它会恢复它以前的状态。一切似乎都适用于 .image
FileStream file = new FileStream(@""+AppDomain.CurrentDomain.BaseDirectory+ "\\objects\\savegame"+spacing+".sav", FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(file);
for (Int32 i = 0; i <columns; i++)
{
for (Int32 j = 0; j < columns; j++)
{
sw.WriteLine(map[i][j].Enabled);
sw.WriteLine(map[i][j].Enabled);
sw.WriteLine(map[i][j].Image);
sw.WriteLine(map[i][j].Tag);
sw.WriteLine(map[i][j].Text);
sw.WriteLine(map[i][j].Name);
sw.WriteLine( map[i][j].Height);
sw.WriteLine(map[i][j].Width);
}
}
FileStream file = new FileStream(@"" + AppDomain.CurrentDomain.BaseDirectory + "\\objects\\savegame" + spacing + ".sav", FileMode.Create, FileAccess.ReadWrite);
StreamReader sr = new StreamReader(file);
for (Int32 i = 0; i < columns; i++)
{
for (Int32 j = 0; j < columns; j++)
{
map[i][j].Enabled = Convert.ToBoolean(sr.ReadLine());
map[i][j].Image = Convert.ToString(sr.ReadLine());// this is the problem
map[i][j].Tag = Convert.ToString(sr.ReadLine());
map[i][j].Text = Convert.ToString(sr.ReadLine());
map[i][j].Name = Convert.ToString(sr.ReadLine());
map[i][j].Height = Convert.ToInt32(sr.ReadLine());
map[i][j].Width = Convert.ToInt32(sr.ReadLine());
}
}
sr.Close();
}
//Sample location for the image --->map[i][j].Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "objects\\map\\mapgrass" + spacing + ".png");