不要在文件中写入新值 [英] don't write new value in file

查看:57
本文介绍了不要在文件中写入新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用两个按钮和一个RichTextBox创建一个表单,
第一个按钮用于读取文件,第二个按钮用于写入,richtextbox用于显示文件的文本,
当我读取文件并想写任何东西时,我不知道我在流写cod行中必须做什么,
代码是:

i create a form with two button and one richtextbox,
first button for read file and second for write and richtextbox for show text of file,
when i read the file and want to write anything,i dont know what do i must to do in streamwrite line cod,
code is:

private void button1_Click(object sender, EventArgs e)
{
    OpenFileDialog op=new OpenFileDialog();
    op.Filter="Text files|*.txt";
    DialogResult dr = op.ShowDialog();
    StreamReader sr = new StreamReader(op.FileName   );
    richTextBox1.Text = sr.ReadToEnd();
    sr.Close();

}

private void button2_Click(object sender, EventArgs e)
{
    StreamWriter sr = new StreamWriter( here i dont know ??? );
    sr.WriteLine(richTextBox1.Text);

    sr.Close();

}

推荐答案

阅读此内容

http://www.dotnetperls.com/streamwriter [
Read this

http://www.dotnetperls.com/streamwriter[^]

Hope this helps if yes then accept and vote the answer otherwise revert back with your queries
--Rahul D.


这篇关于不要在文件中写入新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆