我創建了一個函數來繪製數據:保存在C#中的txt數據文件到陣列功能
public void ShowGraphData(long lTotalData)
{
double[] dx = new double[lTotalData];
double[] dy = new double[lTotalData];
for (long li = 0; li < lTotalData; li++)
{
dx[li] = GlobalDataClass.dDataArray[li, 0];
dy[li] = GlobalDataClass.dDataArray[li, 1];
}
zedGraphControlStickiness.GraphPane.CurveList.Clear();
GraphPane StickinessPane = zedGraphControlStickiness.GraphPane;
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(dx, dy);
// Add cruves to myPane object
LineItem ProductionCurve = StickinessPane.AddCurve("Insertion Force", spl1, Color.Blue, SymbolType.None);
ProductionCurve.Line.Width = 2.0F;
zedGraphControlStickiness.AxisChange();
zedGraphControlStickiness.Invalidate();
zedGraphControlStickiness.Refresh();
GlobalDataClass.iTotalReadingPoint = lTotalData;
}
然後我使用FILESTREAM打開txt文件:
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
//save data to list array.
}
}
我需要加載txt並在Showgraph函數的lToTalData中將數據保存爲一個數組。 我的文本文件是這樣的:
10,20
20,30
30,40
40,50
50,60
可有一個人幫我,我該怎麼辦這個?
如果您想要將數據保存到文件中或想要從文件加載數據,能否更好地解釋? – Steve
對不起,但我想加載數據。 – Ren