DataSet ds = CreateDynamicDataSet();
ds.WriteXml(@"E:\AppScienti\AppScienti-POSLite\POSLite-Dev\XML\POSLite.xml");
private DataSet CreateDynamicDataSet()
{
DataSet ds = new DataSet("DS");
//ds.Namespace = "StdNamespace";
dtOutletMapping.TableName = "Tables[2]";
ds.Tables.Add(dtOutletMapping);
dtxmlEmployee.TableName = "Tables[0]";
ds.Tables.Add(dtxmlEmployee);
dtxmlOrg.TableName = "Tables[1]";
ds.Tables.Add(dtxmlOrg);
return ds;
}
In above code I have path directly in winform and its working fine, now I want to keep path in app.config
and use a path to write a dataset into file
any possible solution please?
Ensure you have added reference to System.Configuration
. (Right click on project and select "Add Refrence" and find it in ".Net" tab).
Modify the app.config file as shown below: Under appSettings
, add your file name as shown below.
<configuration>
<appSettings>
<add key="xmlFile" value="c:\\users\\test.xml" />
</appSettings>
</configuration>
Now in the code add the namespace
using System.Configuration;
And when you want read the file name, do it as shown below
string filename = ConfigurationManager.AppSettings.Get("xmlFile");
DataSet ds = CreateDynamicDataSet();
ds.WriteXml(filename);