如何在每行文本末尾加分号

bejco 2011-04-19 10:29:39
我从网上找了个代码,但是运行不了了,奇怪的很。大家帮忙看看什么原因,或者由什么方法能实现标题所述功能也可以,非常感谢。代码如下:

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();

}



}

}

}


...全文
541 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bejco 2011-04-19
  • 打赏
  • 举报
回复
哈哈,我知道了,多谢大家。
那段代码没问题。
effun 2011-04-19
  • 打赏
  • 举报
回复
除了变量命名有些怪异以外,没有发现什么问题啊。不知道楼主的问题是程序运行不起来还是运行起来达不到预期的效果,请再说明得详细一点。
bejco 2011-04-19
  • 打赏
  • 举报
回复
不用WriteLine吗?
636f6c696e 2011-04-19
  • 打赏
  • 举报
回复
readline()
+ ";"
拼接
就ok了

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧