请问关于c的具体应用场景有哪些?
- 内容介绍
- 文章标签
- 相关推荐
本文共计285个文字,预计阅读时间需要2分钟。
简要改写伪原创以下开头内容,不要啰嗦,不超过100字,直接输出结果:'废话不多说,直接上代码 // summary // 获得当前绝对路径 // summary // /summary // param name=strPath 指定的路径 // param // returns 绝对路径 public static string GetMapPath(string strPath) { if (strPath.ToLower().StartsWith(c:)) { return C:\\\ + strPath.Substring(2); } else { return Application.StartupPath + \\ + strPath; } }'
csharp直接获取路径,无需多余说明。参数strPath指定路径,返回绝对路径。示例:GetMapPath(folder/subfolder)。
废话不多说,直接上代码
/// <summary> /// 获得当前绝对路径 /// </summary> /// <param name="strPath">指定的路径</param> /// <returns>绝对路径</returns> public static string GetMapPath(string strPath) { if (strPath.ToLower().StartsWith("")) { return strPath; } if (HttpContext.Current != null) { string path = HttpContext.Current.Server.MapPath("~/" + strPath); return path; } else //非web程序引用 { strPath = strPath.Replace("/", "\\"); if (strPath.StartsWith("\\")) { strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\'); } return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); } }
以上这篇c# 获得当前绝对路径的方法(超简单)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。
本文共计285个文字,预计阅读时间需要2分钟。
简要改写伪原创以下开头内容,不要啰嗦,不超过100字,直接输出结果:'废话不多说,直接上代码 // summary // 获得当前绝对路径 // summary // /summary // param name=strPath 指定的路径 // param // returns 绝对路径 public static string GetMapPath(string strPath) { if (strPath.ToLower().StartsWith(c:)) { return C:\\\ + strPath.Substring(2); } else { return Application.StartupPath + \\ + strPath; } }'
csharp直接获取路径,无需多余说明。参数strPath指定路径,返回绝对路径。示例:GetMapPath(folder/subfolder)。
废话不多说,直接上代码
/// <summary> /// 获得当前绝对路径 /// </summary> /// <param name="strPath">指定的路径</param> /// <returns>绝对路径</returns> public static string GetMapPath(string strPath) { if (strPath.ToLower().StartsWith("")) { return strPath; } if (HttpContext.Current != null) { string path = HttpContext.Current.Server.MapPath("~/" + strPath); return path; } else //非web程序引用 { strPath = strPath.Replace("/", "\\"); if (strPath.StartsWith("\\")) { strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\'); } return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath); } }
以上这篇c# 获得当前绝对路径的方法(超简单)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

