.net - 将字符串拆分为行并使用.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:\BI\projet\dotnet2.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);
}
解决方案
我能够找到如下所示的解决方案
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);
}
推荐阅读
- list - 列表作为可选构造函数参数在 Dart 中为空
- postgresql - docker-compose:在 cron 作业中转储 postgres 数据库不起作用
- r - 如何使用 ggplot 将一个自变量拆分为另一个以进行绘图
- delphi - 窗口在对接/脱离时松开手柄
- python - 什么是多处理模块中的上下文对象以及它的用途
- vue.js - AWS Websocket 连接响应
- c# - 将 WinForm 滑入和滑出屏幕
- postgresql - /var/lib/postgres/data 存在但不为空
- powerbi - 计算制作食谱所需的包装数量
- javascript - PhotoSwipe.js 中的自定义下载图像