.net core 获得路径
asp.net:
C# 全选
System.Web.HttpContext.Current.Server.MapPath("~/App_Data/tmp/");
winform:
C# 全选
System.AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\tmp\\";
C# 全选
AppDomain.CurrentDomain.RelativeSearchPath
C# 全选
if (HttpContext.Current == null)
{
serverLogPath = AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\tmp\\";
}
else
{
serverLogPath = HttpContext.Current.Server.MapPath("~/App_Data/tmp/");
}
获取当前运行程序
windows app的执行路径 AppDomain.CurrentDomain.BaseDirectory
asp.net的执行路径AppDomain.CurrentDomain.SetupInformation.PrivateBinPath
或者AppDomain.CurrentDomain.RelativeSearchPath
后者获取回来是带有“bin”文件夹在后面的
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post 张国生