Home > Back-end >  I need to upload and read image files to folder that is not part of my project folder Asp.NET MVC 5.
I need to upload and read image files to folder that is not part of my project folder Asp.NET MVC 5.

Time:09-27

I need to upload and read image files to folder that is not part of my project folder. My site is hosting in IIS server. I have already save files in my project folder. There's no an issue. But I need to change that to outside folder. How can I do this? I'm using .NET 4.5.2.

This is what I using now

            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);

CodePudding user response:

But I need to change that to outside folder. How can I do this?

You'd change it to another folder by changing it to another folder:

string imagepath = Path.Combine(@"C:\Whatever\folder\you\want", filename);
  • Related