如何在 ASP.NET Core 1.0 中获取 bin 文件夹

How to get bin folder in ASP.NET Core 1.0(如何在 ASP.NET Core 1.0 中获取 bin 文件夹)
本文介绍了如何在 ASP.NET Core 1.0 中获取 bin 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 asp.net core 1.0 中添加了很多功能.但是没有办法获得 Bin 文件夹路径.

With asp.net core 1.0 There are lots of functionality added. But there is not way to get Bin Folder path.

谁能知道我们如何获取 asp.net core 1.0 应用程序的 bin 文件夹路径.

Can anyone please know how we can get the bin folder path for asp.net core 1.0 application.

推荐答案

好吧,bin 文件夹确实存在,但它被移动到解决方案文件旁边的 artifacts 文件夹.由于 ASP.NET Core RC 1 编译内存中的所有内容,您会发现空的 bin 文件夹.但是如果你将生成时生成输出"选项设置为 true(右键单击项目文件 -> 属性和生成选项卡),那么你会在 bin 文件夹中找到生成的文件.

Well, the bin folder does exists but it is moved to artifacts folder next to the solution file. Since ASP.NET Core RC 1 compiles everything in memory, you will find empty bin folder. But if you set "Produce output on build" option to true (Right click Project file -> Properties and Build tab) then you will find the generated files in bin folder.

我不认为有任何直接属性可用于获取此路径,但您可以使用@Nikolay Kostov 指出的相同解决方案来获取应用程序路径.然后使用 System.IO 类跳转到 bin 文件夹.

I don't think so there is any direct property available as to get the path of this but you can use the same solution pointed out by @Nikolay Kostov to get application path. And then using System.IO classes jump to bin folder.

代码已更新至此处提到的 ASP.NET Core.

http://www.talkingdotnet.com/get-application-wwwroot-path-aspnet-core-rc2/

public Startup(IHostingEnvironment env, IApplicationEnvironment appenv)
{
     string sAppPath = env.ContentRootPath;
     string sRootPath = Path.GetFullPath(Path.Combine(sAppPath, @"...."));
     string sBinFolderPath = @"artifactsin" + appenv.ApplicationName;
     string sBinPath = Path.Combine(sRootPath, sBinFolderPath);
}

这篇关于如何在 ASP.NET Core 1.0 中获取 bin 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)