1

When ASP.NET Core 2 Web Application Reference to .NET Standard Library how to also include folders of ".NET Standard Library" in "ASP.NET Core 2 Web Application".

And in this scenario which base path is used to read file inside ".NET Standard Library".

Like ".NET Standard Library" containing folder called "Templates" with some text files then how to read those files inside ".NET Standard Library" that is referenced by "ASP.NET Core 2 Web Application".

1 Answer 1

2

file

First set the files you want to be read from the folder to the above. Then you can read the files like below:

var bin = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var templateFile = Path.Combine(bin, "Templates", "sample.txt");
var contents = System.IO.File.ReadAllLines(templateFile);

I tested according to the project structure you mentioned and seems to work for me. Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.