【问题标题】:Save file in physical location of an orchard cms module将文件保存在果园 cms 模块的物理位置
【发布时间】:2015-08-25 11:46:42
【问题描述】:

我正在使用 Visual Studio 2013 开发一个果园模块。我想在我的模块文件夹中创建一个文件夹,并在此文件夹中创建一个文本文件。 我试图以这种方式获取我的模块的物理路径:

var areaName = HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"] as string;
var myFolderPath =
                HttpContext.Current.Server.MapPath("/Modules/" + areaName + "/myFolder/");
Directory.CreateDirectory(myFolderPath);

但是myFolderPath 中映射路径的值是C:\Users\myName\Documents\My Web Sites\Orchard.Web-Site\Modules\xxxArea\myFolder,这不是我的果园解决方案的路径。 如何正确获取模块的物理位置?

【问题讨论】:

    标签: orchardcms


    【解决方案1】:

    您可能想要HttpContext.Current.Server.MapPath("~/Modules/" + areaName + "/myFolder/");注意开头的波浪号,这使它看起来像您网站的根目录。

    【讨论】:

    • 谢谢@David。这是我的疏忽!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 2011-07-26
    相关资源
    最近更新 更多