我需要上传和读取图像文件到文件夹,这不是我的项目文件夹Asp的一部分.asp.net MVC 5.我的网站是托管在IIS



我需要上传和读取图像文件到文件夹,不是我的项目文件夹的一部分。我的网站是托管在IIS服务器。我已经在我的项目文件夹中保存了文件。没有问题。但我需要把它改成外部文件夹。我该怎么做呢?我使用的是。net 4.5.2。

这是我现在使用的

string filename = Path.GetFileName(objdata.image.FileName);
string imagepath = Path.Combine(Server.MapPath("~/SupplierImages/"), filename);
if (System.IO.File.Exists(imagepath))
{
System.IO.File.Delete(imagepath);
}
objdata.image.SaveAs(imagepath);

但我需要将其更改为外部文件夹。我该怎么做呢?

您可以通过将其更改到另一个文件夹来更改它:

string imagepath = Path.Combine(@"C:Whateverfolderyouwant", filename);

最新更新