当前位置:首页 > C#

c#保存textbox中的字符串到txt文件中

admin11年前 (2015-12-02)C#6957


/********************** 保存接收按钮 *****************************/
        private void SavetxData_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "(*.txt)|*.txt|(*.*)|*.*";
            saveFileDialog.FileName = "文件" + DateTime.Now.ToString("yyyyMMddHHmm") + ".txt";
            //将日期时间作为文件名
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                StreamWriter streamWriter = new StreamWriter(saveFileDialog.FileName, true);
                streamWriter.Write(this.rxtextBox.Text);
                streamWriter.Close();
            }
        }


扫描二维码推送至手机访问。

版权声明:本文由视觉博客发布,如需转载请注明出处。

本文链接:https://www.feelsight.cn/post/8.html

标签: C#TXT文件

“c#保存textbox中的字符串到txt文件中” 的相关文章

 C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)

C#图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)

一、各种旋转、改变大小 注意:先要添加画图相关的using引用。 //向右旋转图像90°代码如下: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {…

C#图片处理示例(裁剪,缩放,清晰度,水印)

using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Drawing; using System.Drawing.Drawing2D; using…

C#全局监听Windows键盘事件

1.工具类代码 using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Windows.Fo…

C# 窗体间传值(Form与From之间互相传值)

C# 窗体间传值(Form与From之间互相传值)

1、委托   两个窗体,窗体很简单,只实现改变颜色功能,一看就会: 代码如下,只贴按钮事件代码: 打开Form2按钮事件 private void button1_Click(object send…

c# 委托实现多线程的实例/另一个class类调用控件

c# 委托实现多线程的实例/另一个class类调用控件

一、使用线程在窗体中显示进度条 在Winform应用程序中,经常用进度条显示进度信息。这时候就可能用到多线程。如果不采用多线程控制进度条的话,窗口界面很容易假死(无法看到进度信息,看起来像界面卡住了)。 在这个实例中,我们建立一个窗体,窗体中包括一个后台组件,一个进度条控件。当在主窗体中按…

c#程序闪退日志记录/异常日志

以下代码是程序入口文件 using DDS_Form1; using System; using System.Collections.Generic; using System.IO; //using System.Linq; using System.Windows.Forms;…

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。