static void Main(string[] args)
{
string txt = "";
StreamReader sr = new StreamReader(@"E:\test.txt",Encoding.GetEncoding("gb2312"));//读文件流,后面的文件标码不可少,不然有汉字就是乱码。
StreamWriter sw = new StreamWriter(@"E:\123.txt", true, Encoding.GetEncoding("gb2312"));//写文件流,
string[] s1 = new string[600];
int i = 0;
while (!sr.EndOfStream)
{
string str = sr.ReadLine();
s1[i] = str.Replace(" ","");//去除空格
//s1[i]= SubString(str,1,2);//从1位置截取2个字符
sw.Write(s1[i]+"\r\n");
i++;
txt += str + "\n";
}
sr.Close();
Console.Write(txt);
for (int j = 0; j < 234; j++)
{
sw.Write(s1[i]);
Console.WriteLine(s1[i]);
}
sw.Close();
Console.ReadLine();
这两天帮老师整企业录入,要涉及到去除空格,提取地址中的省份、地区等操作,数据量较大,所以写了个简单的程序瞬间完成。呵呵·····水平有限,也就能写出这档次