System.Web.HttpServerUtility.MapPath C# (CSharp) Method

MapPath() public method

public MapPath ( string path ) : string
path string
return string
		public string MapPath (string path)
		{
			return context.Request.MapPath (path);
		}

Usage Example

        public static void AddErrorLog(string strSql, string exStr)
        {
            try
            {
                StreamWriter sw;
                DateTime     Date = DateTime.Now;
                if (!Directory.Exists(HttpContext.Current.Server.MapPath("../log/")))
                {
                    Directory.CreateDirectory(HttpContext.Current.Server.MapPath("../log/"));
                }
                System.Web.HttpServerUtility Server = System.Web.HttpContext.Current.Server;
                string   fileName = DateTime.Now.ToString("yyyyMMdd") + ".txt";
                FileInfo fi       = new FileInfo(Server.MapPath("../log" + "/" + fileName));

                if (fi.Exists)
                {
                    sw = File.AppendText(Server.MapPath("../log" + "/" + fileName));
                }
                else
                {
                    File.Create(Server.MapPath("../log") + "/" + fileName).Close();
                    sw = File.AppendText(Server.MapPath("../log" + "/" + fileName));
                }
                sw.WriteLine("*----------------------------------------------------------");
                sw.WriteLine("err_Time:" + Date.ToString("yyyy-MM-dd HH:mm:ss") + "");
                sw.WriteLine("err_SqlStr:" + strSql + "");
                sw.WriteLine("err_ExStr:" + exStr);
                sw.WriteLine("----------------------------------------------------------*");
                sw.Flush();
                sw.Close();
            }
            finally
            {
            }
        }
All Usage Examples Of System.Web.HttpServerUtility::MapPath