怎么获取richtextbox里的文件的路径
展开全部
private void open_Click(object sender, EventArgs e)
{
OpenFileDialog opfd = new OpenFileDialog();
if (opfd.ShowDialog() == DialogResult.OK) {
//需要是固定的格式
richTextBox1.LoadFile(opfd.FileName,RichTextBoxStreamType.RichText);
}
}
private void save_Click(object sender, EventArgs e)
{
//保存
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK) {
richTextBox1.SaveFile(sfd.FileName);
}
}
方法二:Using system.IO;
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK) {
StreamWriter sw=new StreamWriter (sfd.FileName);
sw.Write(RichTextBox.Text);
}
}
{
OpenFileDialog opfd = new OpenFileDialog();
if (opfd.ShowDialog() == DialogResult.OK) {
//需要是固定的格式
richTextBox1.LoadFile(opfd.FileName,RichTextBoxStreamType.RichText);
}
}
private void save_Click(object sender, EventArgs e)
{
//保存
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK) {
richTextBox1.SaveFile(sfd.FileName);
}
}
方法二:Using system.IO;
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() == DialogResult.OK) {
StreamWriter sw=new StreamWriter (sfd.FileName);
sw.Write(RichTextBox.Text);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询