1. Write text file in C#
This article will guide you get line of multiline textbox and write to txt file.
1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel;
4: using System.Data;
5: using System.Drawing;
6: using System.Linq;
7: using System.Text;
8: using System.Windows.Forms;
9: using System.IO;
10:
11: namespace Write_text_file
12: {
13: public partial class Form1 : Form
14: {
15: public Form1()
16: {
17: InitializeComponent();
18: }
19:
20: private void button1_Click(object sender, EventArgs e)
21: {
22: TextWriter tw = new StreamWriter("C:test.txt");
23: string[] mystring = textBox1.Text.Split(new char[] { 'n' });
24: for (int i = 0; i < mystring.Length; i++)
25: {
26: tw.WriteLine(mystring[i].ToString().Trim());
27: }
28: tw.Close();
29: }
30: }
31: }
Download Source Code