这里我有两个xsd文件,如one.xsd和two.xsd等。
在one.xsd中有3个数据表,在two.xsd中有2个数据表。从那个one.xsd文件中我需要将所有3个数据表名称都放入组合框中。
foreach (var file in System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "*.xsd"))
{
string[] strxsd = file.Split('\\');
string str = strxsd[7].ToString();
DataTable tblFiles = new DataTable();
tblFiles.Columns.Add("Filename");
DataRow dr = tblFiles.NewRow();
dr[0] = str;
tblFiles.Rows.Add(dr);
dtfill.Merge(tblFiles);
cmbXsd.DataSource = dtfill;
cmbXsd.DisplayMember = dtfill.Columns[0].ToString();
cmbXsd.ValueMember = dtfill.Columns[0].ToString();
}
由于
答案 0 :(得分:0)
if (cmbXsd.SelectedIndex == 0)
{
cmbDt.Items.Clear();
XmlDataDocument xmldd = new XmlDataDocument();
DataSet ds = xmldd.DataSet;
for (int j = 0; j <= dtfill.Rows.Count - 1; j++)
{
string filename = dtfill.Rows[j][0].ToString();
string dirpath = Path.Combine(Directory.GetCurrentDirectory(), filename);
ds.ReadXmlSchema(dirpath);
DataTableCollection dtc = ds.Tables;
for (int i = 0; i < dtc.Count; i++)
{
DataTable dt = ds.Tables[i];
GetTableNames(ds);
break;
}
break;
}
}