我想从同一个目录中读取 2 个 excel 文件并将它们的完整路径存储在两个不同的变量中。
例如,
C:\\Users\\User\\Desktop\\Folder\\File1.xlsx - First value
C:\\Users\\User\\Desktop\\Folder\\File2.xlsx - Second value
我string
为此准备了一个数组,但它不起作用。
请帮忙。
我做了以下事情:
string[] location = new string[2];
int i = 0;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
this.openFileDialog1.Filter = "Excel|*.xlsx;*.xlxm;*.xls | All files (*.*)|*.*";
this.openFileDialog1.Multiselect = true;
this.openFileDialog1.Title = "Select Excel Files";
DialogResult dr = this.openFileDialog1.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{
foreach (String file in openFileDialog1.FileNames)
{
location[i] = Path.GetDirectoryName(file);
i++;
}
}