Commas & Periods
English Culture
Depending on the user’s culture settings, their computer may be set up to use commas instead of periods for decimal separators. This can cause problems when writing numbers into xml files and reading these xml files on a different culture setting.
An easy way around this problem is to temporarily adjust the application’s culture settings when reading/writing files to always use a single culture…
// save current culture System.Globalization.CultureInfo current_culture = System.Threading.Thread.CurrentThread.CurrentCulture; // create and set english-us culture System.Globalization.CultureInfo us_culture = new System.Globalization.CultureInfo("en-us"); System.Threading.Thread.CurrentThread.CurrentCulture = us_culture; int rc = WriteMyFile( filename ); // restore the saved culture System.Threading.Thread.CurrentThread.CurrentCulture = current_culture;