本文介绍了如何使用C#解析下面提到的文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

Record FileRecord "1" {
	Record LotRecord "abcd" {
		Field a 1{"NONE"}
		Field b 2 {2, 3}
		Field C 3 {"None", "a", "b"}
		Field d 1 {0}
		List ClassLookupList {
			Columns 3 { int32 CLASSNUMBER, string CLASSNAME, string CLASSCODE }
			Data 5{
				0 "aa" "";
				1 "bb" "";
				2 "cc" "";
				3 "dd" "";
				4 "ee" "";
			}
		}
		Record DataRecord "377" {
			Field a 2 {0, 0}
			Field b 1 {""}
			Field C 7 {"None", "", "", "", "", "", ""}
			List DefectList {
				Columns 14 { int32 DEFECTID, int32 XREL, int32 YREL, int32 XINDEX, int32 YINDEX, int32 XSIZE, int32 YSIZE, float DEFECTAREA, int32 DSIZE, int32 CLASSNUMBER, int32 TEST, int32 ROUGHBINNUMBER, int32 FINEBINNUMBER, int32 REVIEWSAMPLE }
				Data 3{
					1 134312000 133394000 0 0 0 0 0.0 758 0 6 0 0 0;
					2 150981000 115346000 0 0 0 0 0.0 299 0 6 0 0 0;
					3 194310000 137293000 0 0 0 0 0.0 300 0 6 0 0 1;				}
			}

	}
	Field FileTimestamp 2 {"09-10-2018", "09:28:46"}
}
EndOfFile;





我的尝试:





What I have tried:

using (var reader = new StreamReader(fileName))
				{
					string line = null;//await reader.ReadToEndAsync();
					while ((line = await reader.ReadLineAsync()) != null)
					{
						if (!string.IsNullOrWhiteSpace(line) || !string.IsNullOrWhiteSpace(line.Split(',')[0]))
						{
							if (line.Contains("1.8"))
								await GetData(reader.ReadLine());
							else
								return null;
						}
					}



				}





这种方法需要大量编码。有人可以用更好的方法帮助我吗?



This approach will take lot of coding. Could someone please help me with better approach?

推荐答案


这篇关于如何使用C#解析下面提到的文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:44