参考StreamReader.ReadLine 方法
解决方案 »
- 大家来看盾这条SQL语句
- 关于前台和后台
- asp.net菜鸟SOS,SOS!!!!!!!
- 离开某页面前提示问题!急。。。
- 请教ASP.NET里获得视频播放位置点的方法?我知道jsp里可用document.form1.real.GetPosition()方法。
- 如何编译WebForm1.aspx.cs文件?
- 在线调查如何禁止一个人多次提交!谢了,散分(100)!
- ·如何获取repeater的行?(简单)
- 我想要在dATAGRID里,用一个IMAGBUTTON激发一个存储工程
- 怎么用c#做文件上传,下载
- 请各位高手帮帮忙
- 在ASP.NET中用程序添加HtmlControls时,怎样将控件不作为服务器控件,只作为表现控件?
然后对每行进行处理,方法有很多,在最后加两个逗号,
或者用string.Replace()把3个逗号换成5个逗号
System.IO.StreamReader sr = new StreamReader(fs);
string input;
while ((input=sr.ReadLine())!=null)
{
string strTmp = sr.ReadLine();
Response.Write(strTmp+"<br>");
}
---------------------------------------
这样来搞定,但输出来的中文是乱码
{
if (File.Exists(path))
{
File.Delete(path);
} using (StreamReader sr = new StreamReader(path))
{
string x = sr.ReadToEnd();
x = x.Replace("\r\n",",,\r\n");
sr.Close();
sr.Dispose();
using (StreamWriter sw = new StreamWriter(path))
{
sw.WriteLine(x);
sw.Close(); }
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
using System.IO;
using System.Text;
public class MakeFile
{
static string path = @"D:\CSharp\Basic\File.txt";
public static void Main()
{
StringBuilder res = new StringBuilder();
using(StreamReader reader = new StreamReader(path, Encoding.GetEncoding("GB2312")))
{
string line = "";
while((line = reader.ReadLine()) != null)
{
line += ",,\n";
res.Append(line);
}
}
Console.Write(res.ToString());
Console.Read();
}
}
System.IO.StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312"));
string input;
while ((input=sr.ReadLine())!=null)
{
string strTmp = sr.ReadLine();
strTmp = strTmp + ",,";
Response.Write(strTmp+"<br>");
}
--------------------------------------------------------------
这样可以,但现在我想通过strTmp = strTmp + ",,";转化后立即覆盖原来的dw.txt文件,该如何实现,谢谢
StreamWriter sw = new StreamWriter(path)
这样好像不行呢
或者好象有专门的file类吧
我没用过,但原来接触过
你自己看一下