Articles → .NET → Read Resource File In C#
Read Resource File In C#
What Is A Resource File?
How To Create Resource File In Visual Studio?
- Right click on the project and click on ‘Add New Item’
- From the General tab, select ‘Resource File’
Click to Enlarge
Adding Data In Resource File
Click to Enlarge
Reading Resource File In C#
System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Reading_resource_file.Resource1", System.Reflection.Assembly.GetExecutingAssembly());
Console.WriteLine(rm.GetString("Name"));
Console.WriteLine(rm.GetString("URL"));
- Project namespace is ‘Reading_resource_file’
- Folder name – As resource file is placed on the root folder of the project so we can ignore folder name.
- Resource – This is the file name of the resource file without extension.
Click to Enlarge