Само да обърна внимание, че в тази част от MainForm.cs:
- Код: Избери целия код
public partial class MainForm : Form
{
Popul pl;
string fileName;
string[] lv;
RuleDialog rd;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
lv = new string[27];
for(int c = 0; c < 27; c++)
lv[c] = new string('0', 27);
fileName
= @"C:\Users\Добромир.Asus-PC\Documents\Documents\My Documents - Dobromir\C#\Games\Живот with Menu\Lives\Untitled";
}
void ToolStripMenuItem1Click(object sender, EventArgs e)
{
}
void ToolStripMenuItem2Click(object sender, EventArgs e)
{
}
void ExitToolStripMenuItemClick(object sender, EventArgs e)
{
Application.Exit();
}
void NewToolStripMenuItemClick(object sender, EventArgs e)
{
for(int c = 0; c < 27; c++)
lv[c] = new string('0', 27);
fileName
= @"C:\Users\Добромир.Asus-PC\Documents\Documents\My Documents - Dobromir\C#\Games\Живот with Menu\Lives\Untitled";
this.Invalidate();
}
void OpenToolStripMenuItemClick(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory
= @"C:\Users\Добромир.Asus-PC\Documents\Documents\My Documents - Dobromir\C#\Games\Живот with Menu\Lives";
openFileDialog1.RestoreDirectory = false;
openFileDialog1.DefaultExt = "liv";
openFileDialog1.Filter = "live files (*.liv)|*.liv";
openFileDialog1.FilterIndex = 1;
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.ShowDialog();
fileName = openFileDialog1.FileName;
using(StreamReader rd = new StreamReader(fileName))
{
int c = 0;
while(!rd.EndOfStream)
{
lv[c] = rd.ReadLine();
c++;
}
}
this.Invalidate();
}
void SaveToolStripMenuItemClick(object sender, EventArgs e)
{
using (StreamWriter wr = new StreamWriter(fileName))
{
for(int c=0; c<27; c++)
wr.WriteLine(lv[c]);
}
}
void SaveAsToolStripMenuItemClick(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory
= @"C:\Users\Добромир.Asus-PC\Documents\Documents\My Documents - Dobromir\C#\Games\Живот with Menu\Lives";
saveFileDialog1.RestoreDirectory = false;
saveFileDialog1.DefaultExt = "liv";
saveFileDialog1.Filter = "live files (*.liv)|*.liv";
saveFileDialog1.FilterIndex = 1;
saveFileDialog1.CheckFileExists = false;
saveFileDialog1.CheckPathExists = true;
saveFileDialog1.ShowDialog();
fileName = saveFileDialog1.FileName;
using (StreamWriter wr = new StreamWriter(fileName))
{
for(int c=0; c<27; c++)
wr.WriteLine(lv[c]);
}
}
за fileName и InitialDirectory съм задал пълните пътища според файловата система на МОЯ компютър. Когато разархивирате .rar - файла на своя, ще трябва да ги промените според собствената си файлова система. А може би ще можете да промените кода така, че да минете без дословно задаване на пътя - сигурно има начин да накарате компилатора да сложи Вашия път без да го изписвате. Ако някой се сети как да стане, ще се радвам, ако сподели тук.

Меню