Search code examples
c#resourcesembedded-resourcexelement

Edit resource file C#


I added to my c# project an XML file as a Resource file (Resources -> Add Resource (down arrow) add existing file.)

I am reading from the file with no problems :

static XElement resource;
static List<PageType> allPageType;
    

   static public List<PageType> getAllPageLayout()
    {
        
        try 
        {
             resource = XElement.Parse(Properties.Resources.PageTypeConfig);
          
        }
        catch { }
        var query = from p in resource.Elements()
                    select new PageType() 
                    {
                        name = p.Element("name").Value,
                        columnNumber = Int32.Parse(p.Element("ColNumber").Value),
                        rowNumber = Int32.Parse(p.Element("rowNumber").Value),
                        columnWidth = Double.Parse(p.Element("colWidth").Value),
                        rowHeight = Double.Parse(p.Element("rowHeight").Value)
                    }; 
        
        return query.ToList();
    }

but I could not find way to add or modify the resource file element.


Solution

  • It's not possible to change embedded resources.