我想把一个Text Box 中的内容 写进 一个 文本文档中 其中 包括 换行符
请问应该怎么做 呢
请问应该怎么做 呢
解决方案 »
- 【在线等】【急】求助啊,异步tcp中使用了与请求的协议不兼容的地址。
- C#书上的一个static例子,不是很明白
- 多线程Thread是否可以传参数?可以的话应该怎么传?希望哪位高手能指导下。在线等。
- C#中读取报表文件并导出保存到excel文件中是乱码?或者说我的做法有误,报表文件根本不能导出到excel里吗?
- webservice的问题
- c# webbrowser如何判断页面中的元素(文本框)是否存在?
- 超难问题:有没有好办法解决大量数据录入的问题
- 关于执行命令行的等待
- 怎么用代理(本人是教育网,不能直接登陆国外网站)登陆 MSN Messager ?
- 关于Utility Library中ProgressBarEx的一个问题
- 窗体上TreeView的更新(数据库)
- 如何合并字符串中相同分类的值!!!
writer.Write(TextBox1.Text);
writer.Flush();
writer.Close()
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace TestWriteDownTextBoxContext
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.TextBox textBoxObject;
private System.Windows.Forms.Button buttonObject; public Form1()
{
InitializeComponent(); textBoxObject = new System.Windows.Forms.TextBox();
textBoxObject.Text = "";
textBoxObject.Multiline = true;
textBoxObject.Anchor = AnchorStyles.Left|AnchorStyles.Right|AnchorStyles.Top|AnchorStyles.Bottom;
textBoxObject.Location = new System.Drawing.Point(10,10);
textBoxObject.Size = new System.Drawing.Size(200,135); buttonObject = new System.Windows.Forms.Button();
buttonObject.Text = "&Save";
buttonObject.Location = new System.Drawing.Point(230,135);
buttonObject.Size = new System.Drawing.Size(60,20); this.ClientSize = new System.Drawing.Size(296,162);
this.Controls.Add(this.textBoxObject);
this.Controls.Add(this.buttonObject);
this.buttonObject.Click += new System.EventHandler(this.buttonObject_Click);
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
} private void buttonObject_Click(object sender, System.EventArgs e)
{
StreamWriter textBoxStreamWriter = new StreamWriter("C:\\test.txt",false);
textBoxStreamWriter.Write(textBoxObject.Text);
textBoxStreamWriter.Close();
MessageBox.Show("File save to C:\\test.txt");
}
}
}
textBoxStreamWriter.Close();