I measure the Time of a wav File and got it back in a TimeSpan. When I look into the Timespan the totalSeconds value is the exact time i need! For example: TotalSeconds = 6.6999999999999993 When I write it into a File, it will be roundet to 6.7!
I need the exact value in the textfile!
Here is the code:
TimeSpan duration = GetWavFileDuration(wav);
string[] wavStrings = wav.Split('\\');
using (TextWriter writer = new StreamWriter(wav.Replace(".wav", ".plist"), false, Encoding.UTF8))
{
writer.NewLine = "\n";
writer.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" +
"<plist version=\"1.0\">\n" +
"<dict>\n" +
"\t<key>bundle_id</key>\n" +
"\t<string>" + folderStrings[folderStrings.Length - 1] + "</string>\n" +
"\t<key>channels</key>\n" +
"\t<integer>2</integer>\n" +
"\t<key>duration</key>\n" +
"\t<real>" + duration.TotalSeconds.ToString().Replace(',', '.') + "</real>\n" +
"\t<key>filetitle</key>\n" +
"\t<string>" + wavStrings[wavStrings.Length - 1] + "</string>\n" +
"\t<key>sender</key>\n" +
"\t<string>" + folderStrings[folderStrings.Length - 1] + "</string>\n" +
"</dict>\n" +
"</plist>");
}