using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace 最近项目
{
public partial class Form1 : Form
{
string address;
public Form1()
{
InitializeComponent();
address = System.Environment.CurrentDirectory;
}
private void ShowWindows(string fileName)
{
Image p = Image.FromFile(fileName);
Form f = new Form();
f.MdiParent = this;
f.BackgroundImage = p;
f.Show();
} private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = "";
this.openFileDialog1.ShowDialog();
StreamWriter sw = new StreamWriter(address + "\\Menu.ini", true);
sw.WriteLine(openFileDialog1.FileName);//写入INI文件
sw.Flush();
sw.Close();
ShowWindows(openFileDialog1.FileName);
} private void Form1_Load(object sender, EventArgs e)
{
StreamReader sr = new StreamReader (address + "\\Menu.ini");
int i = this.文件ToolStripMenuItem.DropDownItems.Count - 2;
while (sr.Peek() >= 0)
{
ToolStripMenuItem menuItem = new ToolStripMenuItem(sr.ReadLine());
this.文件ToolStripMenuItem.DropDownItems.Insert(i, menuItem);
i++;
menuItem.Click += new EventHandler(menuItem_Click);
}
sr.Close();
} void menuItem_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
错误提示:找不到指定路径的Menu.ini文件。
请高手指点啊!!!!!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;namespace 最近项目
{
public partial class Form1 : Form
{
string address;
public Form1()
{
InitializeComponent();
address = System.Environment.CurrentDirectory;
}
private void ShowWindows(string fileName)
{
Image p = Image.FromFile(fileName);
Form f = new Form();
f.MdiParent = this;
f.BackgroundImage = p;
f.Show();
} private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = "";
this.openFileDialog1.ShowDialog();
StreamWriter sw = new StreamWriter(address + "\\Menu.ini", true);
sw.WriteLine(openFileDialog1.FileName);//写入INI文件
sw.Flush();
sw.Close();
ShowWindows(openFileDialog1.FileName);
} private void Form1_Load(object sender, EventArgs e)
{
StreamReader sr = new StreamReader (address + "\\Menu.ini");
int i = this.文件ToolStripMenuItem.DropDownItems.Count - 2;
while (sr.Peek() >= 0)
{
ToolStripMenuItem menuItem = new ToolStripMenuItem(sr.ReadLine());
this.文件ToolStripMenuItem.DropDownItems.Insert(i, menuItem);
i++;
menuItem.Click += new EventHandler(menuItem_Click);
}
sr.Close();
} void menuItem_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
错误提示:找不到指定路径的Menu.ini文件。
请高手指点啊!!!!!
可以用Application.StartPath得到应用程序路径