111,126
社区成员
发帖
与我相关
我的任务
分享 #region String GetCurrentFullPath() // 获取当前地址(通用,即可获得WinForm运行根目录也可获得Web IIS虚拟根目录
/// <summary>
/// 获取当前地址
/// </summary>
/// <returns>当前地址</returns>
public String GetCurrentFullPath()
{
String CurrentCodeBase = Assembly.GetExecutingAssembly().CodeBase;
CurrentCodeBase = CurrentCodeBase.Substring(8, CurrentCodeBase.Length - 8);
String[] Sections = CurrentCodeBase.Split(new char[] { '/' });
String Result = String.Empty;
for (int i = 0; i < Sections.Length - 1; i++)
Result += Sections[i] + "\\";
return Result;
}
#endregionSystem .AppDomain .CurrentDomain .BaseDirectory
AppDomain.CurrentDomain.SetupInformation.ApplicationBase
Server.MapPath("");