简体   繁体   中英

I need to upload and read image files to folder that is not part of my project folder Asp.NET MVC 5. My site is hosting in IIS server. Any idea?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM