Reputation: 278
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
Upvotes: 4
Views: 333
Reputation: 818
Use this one
Path.Combine(Environment.CurrentDirectory.ToString(), "Plugins", "MyDemo", "Content", "css", "style.css");
It'll work
Upvotes: 3
Reputation: 818
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
.
Upvotes: 2