在创建文本文件之后,它在我添加的richtextbox 中转义了“新行”,告诉我如何解决该问题 + 在创建具有大名称和大量数据的文件时,它会给出异常。
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace Saver
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
string path = "";
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button1Click(object sender, EventArgs e)
{
if((textBox1.Text != "")&&(richTextBox1.Text != ""))
{
if(radioButton1.Checked == true)
path = @"C:\Users\M.Waqas\Desktop\Saver\Saver\Files\";
path += textBox1.Text + ".txt";
FileStream fs = new FileStream(path,FileMode.Create);
StreamWriter wr = new StreamWriter(fs);
wr.Write(richTextBox1.Text);
MessageBox.Show("Your file create on :" + "\n" + path);
textBox1.Clear();
richTextBox1.Clear();
wr.Close();
fs.Close();
}
}
}
}