僅在一週前開始在C#上工作。 開發一個適配器/程序來處理文件夾中的xml文檔並將輸出寫入excel文件。 我能夠實現任務 - 使用xml,xml.linq類。 - 現在我已經設定了自動化過程。 (以便我可以專注於我的任務的第二部分,處理一組.dat文件)從文件夾中加載多個xml文檔
在上述任務中,我一次讀取每個文檔,然後「聯合」在相似類型的xml上 - (某些他們被分割成多個文件)然後處理它們。
我想對我的程序做什麼,只要將xml文檔傳輸到共享文件夾(windows) - 我希望程序開始處理xml文件並將該過程的輸出寫入excel文件。
任何指針 - 至於如何尋找會有很大的幫助。
************************(update)[ratna:11th Aug 2011,6AM IST]
**********************************sample code**************
class FM
{
static void Main(string[] args)
{
FM LetsLoad = new FM();
IEnumerable<XElement> loadedcustDoc = LetsLoad.LoadCustDocuments();
Cust checkCustTrav = new Cust();
checkCustTrav.CustTrav(loadedcustDoc);
/* to process the loaded documents and to output result to excel
*
*/
//Console.ReadLine();
}
public IEnumerable<XElement> LoadCustDocuments()
{
// Loading Customer **** Start***
XDocument CustDoc1 = XDocument.Load(@"J:\dot\custtemp1.xml");
XDocument CustDoc2 = XDocument.Load(@"J:\dot\custtemp2.xml");
IEnumerable<XElement> CustEList1 = CustDoc1.Root.Descendants("Customer");
IEnumerable<XElement> CustEList2 = CustDoc2.Root.Descendants("Customer");
IEnumerable<XElement> CustEListComb = CustEList1.Union(CustEList2)
return CustEListComb;
}
}
** * ** * ** * ** * ** * ** * *示例代碼端 *** * 謝謝大家提供的輸入。 是的,我想看看添加文件的文件夾。 一旦文件被添加,加載文件進行處理。 在本示例中,處理由Cust類處理。 LoadCustDocuments是我想自動化的方法,以便讀取所有的XML文件,並且只在文件名中加載帶有「cust」的文件,並將它們與「Union」組合成一個IEnumerable並返回進行處理。最好的方式來做負載]
我將閱讀通過提供的輸入,並張貼回來。