こんにちは、このコードを使用して 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
私の問題はどこ
ですか、あなたのアドバイスに感謝します