关于另存为的代码
private void 另存为AToolStripMenuItem_Click(object sender, EventArgs e){
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = "保存为";
dlg.Filter = "txt file(*.txt)[*.txt]all files(*.*)|*.*";
char [] parm = { "\n" };
string lines = richTextBox1.Text.Split(parm);
int i = 0;
char [] trimparam = { "\r" };
foreach (string s in lines)
lines[i++] = s.TrimEnd(trimparam);
try
{
StreamWriter sw = new StreamWriter(dlg.FileName);
foreach (string s in lines)
{
sw.WriteLine(s);
}
sw.Close();
}
catch (Exception ex)
{ MessageBox.Show(ex.ToString(), "提示");
return;
}
}
为什么我用上运行不了、 求解决、谢谢