string filePath = HttpContext.Current.Server.MapPath(htmlpath);
using(StreamWriter sw = new StreamWriter(filePath)){
sw.Write(ContentHtml);
}
这档模样就ok了,注意,你的悉茄这个htmlpath必行陆缓须以你的htm扩展名结尾
using System.IO;//命名空间
string strPath=@"D:\abcdefg\aaa\a.html";
string value="
VS2008中,带者绝保存祥芦和打开文件对话框 ,我工程中的源谨嫌带代码
//将命令窗口的内容保存到文件
private void btnSave_Click(object sender, EventArgs e)
{
StreamWriter sw;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Properties.Resources.FileType;
sfd.ShowDialog();
if (sfd.FileName != null)
{
try
{
sw = new StreamWriter(sfd.FileName);
}
catch
{
return;
}
sw.WriteLine(rtbCommand.Text);
sw.Close();
}
}
//文件内容加载到命令窗口
private void btnOpen_Click(object sender, EventArgs e)
{
StreamReader sr;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = Properties.Resources.FileType;
ofd.ShowDialog();
if (ofd.FileName != null)
{
try
{
sr = new StreamReader(ofd.FileName);
}
catch
{
MessageBox.Show(Properties.Resources.OpenfileError);
return;
}
rtbCommand.Text += sr.ReadToEnd();
sr.Close();
}
}
文件写入