zoukankan      html  css  js  c++  java
  • 向文件中写入追加的数据

    实现效果:

      

    知识运用:

      StramWrite类的构造方法和Write方法

    实现代码:

            private void button2_Click(object sender, EventArgs e)
            {
                if (string.IsNullOrEmpty(textBox1.Text.Trim()))
                {
                    MessageBox.Show("文件还未选择");
                    return;
                }
                if (string.IsNullOrEmpty(textBox2.Text.Trim()))
                {
                    MessageBox.Show("内容不能为空");
                    return;
                }
                try
                {
                    StreamWriter sw = new StreamWriter(textBox1.Text,true);
                    sw.Write(textBox2.Text);
                    sw.Close();
                    MessageBox.Show("文件写入成功!");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message); }
            }
    
  • 相关阅读:
    CSS选择器
    CSS样式与语法
    实训第二天
    初学前端
    html-路径和图像标签
    html
    JavaScript(基础)
    CSS(2)
    CSS()
    HTML(链接与表单)
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10253350.html
Copyright © 2011-2022 走看看