How do I get the current directory in a web service

前端 未结 7 833
情歌与酒
情歌与酒 2020-12-09 08:04

I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the curren

7条回答
  •  感情败类
    2020-12-09 08:34

    HttpContext.Current.Server.MapPath("~/") maps back to the root of the application or virtual directory.

    HttpContext.Current.Server.MapPath("~/") <-- ROOT
    HttpContext.Current.Server.MapPath(".") <-- CURRENT DIRECTORY
    HttpContext.Current.Server.MapPath("..") <-- PARENT DIRECTORY

    All the above is relative, so you can you any combination to traverse the directory tree.

提交回复
热议问题