I\'ve got an issue where I am writing a DataSet to XML that has a column of type DateTime and I want to control the output format.
DataSet data = LoadDataSet
If the file is regular, and the exported XML seems so, you can just rewrite it using simple loop. Easy and quick solution. Use some of my code if you want:
private void rewriteXML(string oldFile, string newFile, int startPos, int strLength)
{
try
{
File.Delete(newFile);
}
catch { Console.WriteLine("File didn't existed."); }
StreamReader SR = new StreamReader(oldFile);
string data;
StreamWriter SW = new StreamWriter(newFile);
while ((data = SR.ReadLine()) != null)
{
if (data.Contains(""))
{
string ln_tmp = data.Replace(" ", "");
string newline = " " + ln_tmp.Substring(startPos, strLength) + " ";
SW.WriteLine(newline);
}
else
SW.WriteLine(data);
}
SR.Close();
SW.Close();
}
The output is like:
19:34
Instead of:
2013-03-17T19:34:00+01:00