NewYorker
NewYorker

Reputation: 73

Create a resource file dynamically

I have an .resx file that contains a few strings. Its path in the Solutions Explorer is:

Resources\main_resource.resx

I am trying to delete and re-create it programmatically using the ResXResourceWriter class.

using (var writer = new ResXResourceWriter(@"../Resources/main_resource.resx"))
writer.AddResource("new string", "new value");

This doesn't work. I get the following error:

Could not find a part of the path 'C:\Users\Joshua\Documents\Visual Studio 2019\MyProject\MyProject\bin\Resources\main_resources.resx

Upvotes: 0

Views: 1114

Answers (1)

Nicholas
Nicholas

Reputation: 87

I am pretty sure you only need to go one more step back, by that I mean you need "../" twice. Please let me know if it works :)

var writer = new ResXResourceWriter(@"../../Resources/main_resource.resx")

Upvotes: 0

Related Questions