A.R.SEIF
A.R.SEIF

Reputation: 873

change resource file (resx file) with c#

in c# by reflection change resource file look like below:

using (ResourceWriter resourceWriter = new ResourceWriter(PathName))
        {
            foreach (var textItem in selectedText)
            {
                resourceWriter.AddResource(textItem.Id, textItem.Name);
            }
        }

a selectedText is List of Id and Name instead of name and value. when run test a destroy resource file and not opening.

Upvotes: 0

Views: 50

Answers (1)

AndrewToasterr
AndrewToasterr

Reputation: 479

I think you are looking for ResXResourceWriter class

using (ResXResourceWriter resourceWriter = new ResXResourceWriter(PathName))
{
    foreach (var textItem in selectedText)
    {
        resourceWriter.AddResource(textItem.Id, textItem.Name);
    }

    resourceWriter.Close();
}

Upvotes: 1

Related Questions