日期:2014-05-17 浏览次数:21332 次
OleDbConnection mycon = null;
try
{
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\1.mdb;";
mycon = new OleDbConnection(strcon);
mycon.Open();
//获取文件名列
string sql = "select 文件名 from temp";
OleDbDataAdapter ad = new OleDbDataAdapter(sql, strcon);
DataSet ds = new DataSet();
ad.Fill(ds,"文件名");
string[] filesName = new string[ds.Tables[0].Rows.Count];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
filesName[i] = ds.Tables[0].Rows[i]["文件名"].ToString();
foreach (string dir in filesName)//遍历所有文件名
{
string fn = "D:\\1"+ @"\" + dir;
XElement element = XElement.Load(fn);
element.Descendants("DataField").Descendants("Data").ToList().ForEach(item => { item.SetAttributeValue("ToCorpID", "0"); });
element.Save(dir);
}
}