The recommended way to handle this is to store the value as a number, not a string. Both in the database and in your program. When you do this, your current problem simply never arises.
The only time you deal with numbers in a string format is when you display them or accept user input. In these scenarios, you can use custom culture settings so that they can see them and use their preferred separator.
If you need to convert a string and a number to save, you must use the culture invariant conversion. This seems to be where you fall. I suspect that the file you are reading does not have a clearly defined format. Make sure you use CultureInfo.InvariantCulture when reading and writing the file. If the file has a well-defined format that differs from the invariant culture, then use the corresponding specific CultureInfo file.
source share