Click here to Skip to main content
15,909,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I seek a little bit of advice...

I have an WPF C# program with an XML resource file in which I have text for some buttons, like a language file (let's call it language.xml), and 2 xml more, for example english.xml and spanish.xml.
I have the XmlDataProvider pointing to language.xml
At startup I seek in a database which language has the user in his/her configuration, and I overwrite language.xml with the content in english.xml or spanish.xml

Sometimes the program loads right, but most of the time it loads the wrong data, although you look in the language.xml and the data is right.
(When I say wrong data I mean loading the program and entering with one user with a language set, closing, and entering with another one with other language...).

It's a little bit confusing, but I hope someone have tried something like this...

Thank you in advance. :)

UPDATE:
OP resolved it - posted that as an answer.
Posted
Updated 20-Jan-11 19:16pm
v2

I suspect that the file system is reporting that the file operation is complete before it actually is, then you're requesting the file so quickly that it doesn't get the new version (it's pulling from cache or something).

There are two ways to fix this.

Since you are far enough along this path, I would likely suggest doing two things in the first approach.
1) Check (and store) the last mod date of the file prior to overwriting the contents.
2) After you overwrite the contents, wait until the last mod date is reported as changed from what you originally captured.

The other approach would be to use .NET's built in globalization support, but that would take a lot of work if you've already built out your own version.

Cheers.
 
Share this answer
 
Ok, got it. I had to reload the XmlDataProvider in the Loaded method.
In addition, seeing that I had to reload the XmlDataProvider itself, I set it to point directly to the correct .xml file. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900