Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to load file from resources in c#

// required
using System.IO;
using System.Reflection;

public string GetEmbeddedResource(string namespacename, string filename)
{
    var assembly = Assembly.GetExecutingAssembly();
    var resourceName = namespacename + "." + filename;

    using (Stream stream = assembly.GetManifestResourceStream(resourceName))
    using (StreamReader reader = new StreamReader(stream))
    {
        string result = reader.ReadToEnd();
        return result;
    }
}
Source by www.codeproject.com #
 
PREVIOUS NEXT
Tagged: #load #file #resources
ADD COMMENT
Topic
Name
2+8 =