找不到路径的一部分:Server.mapPath

时间:2016-08-15 03:04:09

标签: c# asp.net-mvc file

我正在尝试保存横幅图片,然后保存到我正在检查并创建相应文件夹的文件夹,但即使我检查该文件夹存在,它也会给我错误。这是代码:

HttpPostedFileBase banner = Request.Files["banner"];
if (banner != null && banner.ContentLength > 0) {
    var folder = Server.MapPath("~/images/Continents/");
    if (!Directory.Exists(folder)) {
        Directory.CreateDirectory(folder);
    }
    banner.SaveAs(Server.MapPath("~/images/Continents/" + image.FileName));
    string x = "/images/Continents/" + image.FileName;
    continent.BANNER = x;
}

我有什么遗失的吗?

0 个答案:

没有答案