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
Sanjay DPosted Jul 30, 2006, 12:45 PM
hi can u try this
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;
// Please visit this link : http://www.codeproject.com/cs/files/xdirectorycopy.asp
foreach (FileInfo fi in diSourceList[iterator].GetFiles("*.xml")) //File Filter
{
if (File.Exists(strPath+"test["+i+"].xml"))
{
Response.Write("File Exists");
ds.WriteXml(strPath+"test["+i+"].xml",System.Data.XmlWriteMode.DiffGram);
break;
}
i++;
}
else
{
Response.Write("File not exits");
File.Create(strPath+"test["+i+"].xml",4) ;
}
monika vasvaniPosted Jul 24, 2006, 11:45 PM
Dim f As StreamWriter
id1 = id1 + 1
f = File.CreateText(
"c:\inetpub\wwwroot\try1\mydoc " & id1 & ".xml")f.Close()
id1 = id1
U can initialize id1 as 0.
U can write this code in timer using thread.