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

编程入门 行业动态 更新时间:2024-10-19 08:55:46
本文介绍了如何在 ASP.NET Core 1.0 中获取 bin 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

Can anyone please know how we can get the bin folder path for asp 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.

www.talkingdotnet/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 文件夹

本文发布于:2023-11-14 19:45:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   如何在   ASP   Core   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!