【发布时间】:2017-05-15 09:17:40
【问题描述】:
我正在尝试使用 OpenFileDialog.FileNames 存储 XML 并将其添加到我的数组中。没有数据被添加到数组中。请你帮帮我。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
String[] fileNames;
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
ofd.Multiselect = true;
ofd.Filter = "XML Files (*.xml)|*.xml";
foreach (String file in ofd.FileNames)
{
MessageBox.Show(file);
fileNames = file; // Here is where I am getting stuck
}
}
private void button2_Click(object sender, EventArgs e)
{
BackEndCode bec = new BackEndCode();
bec.backCode(fileNames);
}
}
}
感谢您的帮助
【问题讨论】:
标签: c# filenames openfiledialog