ResXResourceWriter Chops off end of file

Posted by Aaron Salazar on Stack Overflow See other posts from Stack Overflow or by Aaron Salazar
Published on 2010-06-01T19:47:38Z Indexed on 2010/06/01 20:03 UTC
Read the original article Hit count: 242

Filed under:
|
|

I'm trying to create a .resx file from a dictionary of strings. Luckily the .Net framework has a ResXResourceWriter class. The only problem is that when I create the file using the code below, the last few lines of my generated resx file are missing. I checked my Dictionary and it contains all the string pairs that I expect.

public void ExportToResx(Dictionary<string,string> resourceDictionary, string fileName)
{
    var writer = new ResXResourceWriter(fileName);

    foreach (var resource in resourceDictionary)
    {
        writer.AddResource(resource.Key, resource.Value);
    }
}

Unfortunately, it is a little difficult to show the entire resx file since it has 2198 (should have 2222) lines but here is the last little bit:

...
2195    <data name="LangAlign_ReportIssue" xml:space="preserve">
2196        <value>Report an Issue</value>
2197    </data>
2198    <data name="LangAlign_Return

BTW, notice that the file cuts off right at the end of that "n" in "LangAlign_Return". The string should read "LangAlign_ReturnToWorkspace". The file should also end at line 2222.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET