嗨,我正在使用此代码通过 ASP.NET MVC 上传文件,一切正常,但无法访问上传文件夹:
public static char DirSeparator = System.IO.Path.DirectorySeparatorChar;
public static string FilesPath = "Content" + DirSeparator + "Uploads" + DirSeparator;
public static string UploadFile(HttpPostedFileBase file)
{
if (null == file) return "";
if (!(file.ContentLength > 0)) return "";
string fileName = file.FileName; string fileExt = Path.GetExtension(file.FileName);
if (null == fileExt) return "";
if (!Directory.Exists(FilesPath))
{
Directory.CreateDirectory(FilesPath);
}
string path = FilesPath + DirSeparator + fileName;
file.SaveAs(Path.GetFullPath(path));
return fileName;
}
我得到这个错误:
Access to '/Content/Upload/' is Denied
我的问题在哪里,
谢谢您的建议