Leorisar
1
Q:

c# read resource json

		// parameter "name" is a name of your file
        // for example: employees.json
        // execution: ReadResource("employees.json");
	public static string ReadResource(string name)
        {
            var assembly = Assembly.GetExecutingAssembly();
            string resourcePath = name;
            if (!name.StartsWith(nameof(Readjson)))
                resourcePath = assembly.GetManifestResourceNames()
                    .Single(str => str.EndsWith(name));
            Stream stream = assembly.GetManifestResourceStream(resourcePath);
            StreamReader reader = new StreamReader(stream);
            return reader.ReadToEnd();
        }
0

New to Communities?

Join the community