C# Server.MapPath的使用

(1)WebForm中:

  HttpContext.Current.Server.MapPath("~/upload/file/");

(2)Mvc中:

  Server.MapPath()

  (3)最底层的写法:

  String path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
             path = string.Format(@"{0}Data\Logs\{1}\", path, DateTime.Now.ToString("yyyy-MM-dd"));//按时间格式保存日志文件

posted @ 2021-10-28 17:21  qingjiawen  阅读(776)  评论(0编辑  收藏  举报