我正在尝试将从我的 openButton 获取的路径名发送到构造函数,以便我可以使用其中的信息。任何人都可以看到如何做到这一点?
namespace GPSCalculator
{
public partial class Form1 : Form
{
private String[] items;
int count = 0;
string FileName;
public Form1()
{
InitializeComponent();
List<float> inputList = new List<float>();
TextReader tr = new StreamReader(FileName);
String input = Convert.ToString(tr.ReadToEnd());
items = input.Split(',');
}
private void openToolStripMenuItem_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))
{
var FileName = (ofd.FileName);
}
}
}
}