C# richtextbox內容儲存成文字檔

C# richtextbox內容儲存成文字檔

C# richtextbox內容儲存成文字檔


 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

 

namespace SYWEB_SYDServer

{

    public partial class Form1 : Form

    {

        public
Form1()

        {

            InitializeComponent();

        }

 

        private
void Form1_Load(object
sender, EventArgs e)

        {

            MessageBox.Show(“message load”);

            this.richTextBox_base1.Text
=
“00” + richTextBox_base1.Text;//
A@¡M¢G¦?a

            this.richTextBox_base1.Text
=
“01\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“02\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“03\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“04\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“05\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“06\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“07\n” + richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“08\n” +
richTextBox_base1.Text;

            this.richTextBox_base1.Text
=
“09\n” +
richTextBox_base1.Text;

            MessageBox.Show(“”+this.richTextBox_base1.Lines.Length);

            string[]
sLines = richTextBox_base1.Lines;

            string[]
sNewLines =
new string[sLines.Length
– 1];

            Array.Copy(sLines,
0, sNewLines, 0, sNewLines.Length);
//
DhÓ?Ia@a

            richTextBox_base1.Lines =
sNewLines;

            StreamWriter
sw = new StreamWriter(“secret.log”);

            int
index = 0;

            foreach
(string element in
sNewLines)

            {

                if
(index > 0)

                {

                    sw.WriteLine(“”);

                }

                sw.Write(element);// gJar

                index++;

            }

            sw.Close();// o?e

        }

    }

}

 

 

 


 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *