我正在尝试保存横幅图片,然后保存到我正在检查并创建相应文件夹的文件夹,但即使我检查该文件夹存在,它也会给我错误。这是代码:
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;
}
我有什么遗失的吗?