string[]strSplit={"**"};
List<string>strList=newList<string>();
StreamReadersr=newStreamReader(strPath,Encoding.Default);
while(!sr.EndOfStream)
{
line=sr.ReadLine();
string[]strArr=line.Split(strSplit,StringSplitOptions.RemoveEmptyEntries);
if(textbox1==strArr[0]&&textbox2==strArr[1])
{
line="";
//
//这里对strArr进行删除修改
//
for(inti=0;i<strArr.Length;i++)
{
line+=strArr[i];
if(i!=strArr.Length-1)
line+="**";
}
}
strList.Add(line);
}
sr.Close();
StreamWritersw=newStreamWriter(strPath,false);
for(inti=0;i<strList.Count;i++)
{
sw.WriteLine(strList[i]);
}
sw.Close();
扩展资料
c#删除记事本某一行
stringfileName="E:/aa.txt";
intn=-1;
StringBuildersb=newStringBuilder();
StreamReadersr=newStreamReader(fileName,Encoding.ASCII);
intnLine=0;
while(sr.Peek()>-1)
{
nLine++;
Strings=sr.ReadLine();
if(nLine!=n&&nLine!=3)
sb.Append(s+"/r/n");
}
sr.Close();
StreamWritersw=newStreamWriter(fileName,false,Encoding.ASCII);
sw.Write(sb.ToString());
sw.Close();
推荐于2017-12-16
string read = s.ReadLine();//读取一行,存放在变量read中
2013-08-06
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{ StreamReader read = new StreamReader(@"文本路径");
Console.Write(read.ReadLine());
}
}
}