将字符串拆分为行,并使用.net检查当前行和下一行的边



在用'\n'将字符串拆分成行之后,当您已经在检查当前行时,如何获得下一行中的内容?现在这是我在.net上使用的:

WebClient Downloadurl = new WebClient();
byte[] myDataBuffer = Downloadurl.DownloadData(url);
string download = Encoding.ASCII.GetString(myDataBuffer);
String newfile = download.Replace("<br>", "n");
String path = @"E:BIprojetdotnet2.csv";
try
{
Create the file, or overwrite if the file exists.
using (FileStream fs = File.Create(path))
{
byte[] info = new UTF8Encoding(true).GetBytes(newfile);
fs.Write(info,0,info.Length);
}
string download = null;
using (var Downloadurl = new WebClient())
{
download = Downloadurl.DownloadString(url).Replace("<br>", "n");
// you may want to do something with `<p>`, too,
// and you should do it in a way that's not case sensitive
}
string path = @"E:BIprojetdotnet2.csv";
using (var reader = new StringReader(download))
using (var writer = new StreamWriter(path, false, Encoding.UTF8))
{
string line = null;
while ( (line = reader.ReadLine()) != null)
{
// Do something with each line!
// Note, this doesn't change the original string
writer.WriteLine(line);
}
}

我能够在下面找到解决方案

StreamReader st = new StreamReader(path);
while (!st.EndOfStream)
{
var slpits = st.ReadLine();
String type = slpits.Substring(0,4);
if (type =="TICN" )
{
ticketid = slpits.Substring(5, 21);
}
if (type =="SCON")
{
slpits =  slpits.Insert(5, ticketid);
}

最新更新