Last few days, I was thinking to jot down all the code snippet that I used very frequently. Here comes the first one –
Today’s post will be covering a simple aspect of every .net project where one has to add files in Resource and get it from there for further processing.
To Add & Get the file from the resource , we have to –
1. Select the file that we want to put in the resource –
And from the property window, set the Build Action = “Embedded Resource”.
2. To get file from the resource, we have to write following few lines of codes –
In this code snippet , as we can see , I am getting the resource from the Assembly Menifest and returning it as XmlReader to the caller as –
And we are done.