GeoSharp
GeoSharp copied to clipboard
Not work with new data format
I download allcountries.txt. run code but its rise error

The format hasn't changed and it works fine, as you see in the screenshot The Value is 42.64991 - which should be easily parsed by double.Parse ... but it doesn't: the Problem is probably your Russian setting.
Does Russian use "," to seperate the decimal?
Compile in a neutral culture or explicitly set the culture to a culture which uses a period for the decimal separator.
Compile in a neutral culture
I'm not sure how one would do that?
or explicitly set the culture to a culture which uses a period for the decimal separator.
Indeed. You can do either:
this.Latitude = double.Parse(Fields[4], CultureInfo.InvariantCulture);
this.Longitude = double.Parse(Fields[5], CultureInfo.InvariantCulture);
Or, alternatively, use this as one of the first lines in your program:
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
Not that the latter changes the culture for the entire application, you might not want that.
Finally, you may want to take a look at NGeoNames (full disclosure: I'm the author) which handles all of the parsing for you.