Skip to content

Instantly share code, notes, and snippets.

@talkingdotnet
Created February 26, 2018 08:02
Show Gist options
  • Save talkingdotnet/7442af2d823a0c4bd816c4dfada31ed2 to your computer and use it in GitHub Desktop.
Save talkingdotnet/7442af2d823a0c4bd816c4dfada31ed2 to your computer and use it in GitHub Desktop.
public void ExtractData()
{
try
{
DataTable dtList = GetTableList();
DataSet ds = new DataSet();
foreach (DataRow row in dtList.Rows)
{
string tableName = row[0].ToString();
DataTable dtData = FetchData(tableName);
ds.Tables.Add(dtData);
}
if (ds.Tables.Count > 0)
{
XmlSerializer ser = new XmlSerializer(typeof(DataSet));
string xmlFileName = "Dbdata.xml";
string fullPath = Path.Combine(_directoryPath, xmlFileName);
using (TextWriter writer = new StreamWriter(fullPath))
{
ser.Serialize(writer, ds);
writer.Close();
}
PrepareZip(fullPath);
File.Delete(fullPath);
}
}
catch (Exception ex) { throw ex; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment