简体   繁体   中英

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.

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM