C#在文本文件的每行后加分号

 

Authorquietwalk

Date2010-10-28


 

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 ReadLine

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void btnConvert_Click(object sender, EventArgs e)

        {

            string oldValue = string.Empty, newValue = string.Empty;

 

            StreamWriter writer = new StreamWriter(@"d:\\diccode_destination.txt", true,Encoding.Default);

            using (StreamReader read = new StreamReader(@"d:\\diccode_orginal.txt", System.Text.Encoding.Default,true))//txt 文件默认是 GB2312格式编码

            {

               

                do

                {

                    newValue = read.ReadLine();

                    oldValue = newValue != null ? newValue+";" : oldValue;

                    writer.WriteLine(oldValue);

                } while (newValue != null);

 

                read.Close();

                writer.Close();

            }

 

        }

    }

}

 

 

 

posted @ 2010-10-28 11:12  quietwalk  阅读(689)  评论(0编辑  收藏  举报