111,129
社区成员
发帖
与我相关
我的任务
分享
byte[] byData = new byte[1000];//长度自己看着办
char[] charData = new char[1000];
try
{
FileStream sFile = new FileStream("C:\\MeasureData.txt", FileMode.Open);
sFile.Seek(0, SeekOrigin.Begin);//设置第一个参数,把t(ms) S1x S1y S1 S2x S2y S2部分忽略掉
sFile.Read(byData, 0, 1000);
}
catch (IOException ex)
{
MessageBox.Show("error");
}
Decoder d = Encoding.UTF8.GetDecoder();
d.GetChars(byData, 0, byData.Length, charData, 0);
StringBuilder sbData = new StringBuilder();
foreach (char temp in charData)
{
sbData.Append(temp);
}
string strData = sbData.ToString();
MatchCollection mats = Regex.Matches(strData + " ", @"([^\s]*?)\s[^\s]*?\s[^\s]*?\s([^\s]*?)\s[^\s]*?\s[^\s]*?\s([^\s]*?)\s");
foreach (Match mat in mats)
{
string strTime = mat.Groups[1].ToString();
string strS1Value = mat.Groups[2].ToString();
string strS2Value = mat.Groups[3].ToString();
//将time,value记入到集合中(自己定义嘛,List<T>,或者直接Point[])
}
//Graphics g= this.CreateGraphics();
//g.DrawCurve(new Pen(),Point[] pts);