-
Notifications
You must be signed in to change notification settings - Fork 10.3k
How do you get current physical path inside Startup.cs? #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Don't use that API. Use the one provided by the framework. In your Startup.cs you can take public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
{
var path = env.ApplicationBasePath;
} The reason you're seeing that AppDomain doesn't exist is because it isn't available on CoreCLR. Your project by default compiles for both frameworks. |
Thanks for your response David. Where does IApplicationEnvironment live? my Configure looks like this, I am using beta3 btw: Error CS1061 'IHostingEnvironment' does not contain a definition for 'ApplicationBasePath' and no extension method 'ApplicationBasePath' accepting a first argument of type 'IHostingEnvironment' could be found (are you missing a using directive or an assembly reference?) Thanks. |
Close, IApplicaitonEnvironment lives in the Microsoft.Framework.Runtime.Interfaces package (which you already reference transitively) |
Thank you. |
How do you get current physical path inside Startup.cs?
I tried so many things and it does not work. On top of that I am experiencing a very very strange behavior.
When I am debugging and type AppDomain.CurrentDomain.BaseDirectory I get the current path.
However I cannot even compile the code as I get this error on run time if I include AppDomain.CurrentDomain.BaseDirectory directly.
The name 'AppDomain' does not exist in the current context
Thanks.
The text was updated successfully, but these errors were encountered: