タイトルが示唆しているように、ストリームリーダーによって取得されたファイルを別のクラスに送信して、そのクラスがそこから情報を抽出できるようにしようとしています。フォーム内でそれを抽出しようとしましたが、これは混乱を招き、確かにそれを行うには不十分な方法です。誰かが方法を提案できますか?
これがファイルを識別するクラスです。
namespace DistanceEstimatorFinal
{
public partial class Form1 : Form
private void openDataListToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "CSV files (*.csv)|*.csv|Text files ( *.txt)|*.txt |All files (*.*)|*.*";
if (ofd.ShowDialog(this).Equals(DialogResult.OK))
{
Stream fileStream = ofd.OpenFile();
using (StreamReader reader = new StreamReader(fileStream))
{
}
}
}
ここに送信する方法が必要です...方法がわかりません:[
namespace DistanceEstimatorFinal
{
public class dataPoints
{
List<dataPoint> Points;
public dataPoints( )
{
Points = new List<dataPoint>();
TextReader tr = new StreamReader();
string input;
while ((input = tr.ReadLine()) != null)
{
string[] bits = input.Split(',');
dataPoint a = new dataPoint(bits[0],bits[1],bits[2]);
Points.Add(a);
}
tr.Close();
}
internal dataPoint getItem(int p)
{
if (p < Points.Count)
{
return Points[p];
}
else
return null;
}
}
}
どんな助けでも大歓迎です