2
Reply

ASP.net XML File Creation

vinod kumar

vinod kumar

Jul 22 2006 7:44 AM
2.6k



 hi all,
 
i am submitting code snippet

string strConnect="user id=hr;data source=ORCESSDB;password=hr";
   OracleConnection Or=new OracleConnection(strConnect);
   Or.Open();
   string strSel2="select * from test2";
   OracleDataAdapter Oa=new OracleDataAdapter(strSel2,Or);
   DataSet ds=new DataSet();
   Oa.Fill(ds);
   
   writeXMLFile(ds);

   Or.Close();
  }
  public void  writeXMLFile(DataSet ds)
  {
   string strPath="C:\\Test\\";

       
    if (Directory.Exists(strPath))
    {
    
     int i=0;
     if (File.Exists(strPath+"test["+i+"].xml"))
     {
      Response.Write("File Exists");
      ds.WriteXml(strPath+"test["+i+"].xml",System.Data.XmlWriteMode.DiffGram);
     }
     else
     {
      Response.Write("File not exits");
      File.Create(strPath+"test["+i+"].xml",4) ; 
     }
     
 .........................
.....................

 i want create a series of xml files 

like test1.xml,test2.xml,test3.xml...............

how will i check the file test1.xml exits or not 

i just assigned a variable int i=0;
how will i get the number of files in a directory



    
    


Answers (2)