asp.net core 2.0 not getting exact path of css or view page

333 views Asked by At

net core 2.0 and i have getting issue to getting full path as shown as given below if you have any idea please give me solution

 string filePath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "Demopath"), "Views"), "DemoViews"), "Views.cshtml");

From this i am getting this path

D:\ILYAS\\nop4.0\Presentation\Nop.Web\bin\Debug\net461\Plugins\Demopath\Views\DemoViews\Views.cshtml

But i don't need \bin\Debug\net461\

becuase of this extra line i am not getting my CSS and view page Is any one have idea please inform me

thank you in advance

2

There are 2 answers

0
Raju Paladiya On BEST ANSWER

Use this one

Path.Combine(Environment.CurrentDirectory.ToString(), "Plugins", "MyDemo", "Content", "css", "style.css");

It'll work

3
Raju Paladiya On

Path seems combining proper. Look at path

Plugins\Demopath\Views\DemoViews\Views.cshtml

it seems merged proper.

Your issue at AppDomain.CurrentDomain.BaseDirectory

You can use store url instead of BaseDirectory or something else.

Or you can go to root directory to Nop.Web

or use direct path using Server.MapPath("YourPath").

Server.MapPath is easy to use multiple time Path.Combine.