我想存儲使用OpenFileDialog.FileNames的XML並將其添加到我的數組中。沒有數據被添加到數組中。請你幫我解決。OpenFileDialog FileNames
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);
}
}
}
謝謝您的幫助
謝謝Michal :) –