C#.NET Server类操作
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace Pub.Class {
/// <summary>
/// Servers类
/// </summary>
public class Server2 {
/// <summary>
/// 获得当前绝对路径
/// </summary>
/// <param name="strPath">指定的路径</param>
/// <returns>绝对路径</returns>
public static string GetMapPath(string strPath)
{
if(HttpContext.Current != null)
return HttpContext.Current.Server.MapPath(strPath);
else //非web程序引用
return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
}
}
}
开源:
https://github.com/hcxiong 欢迎收藏:)