簡體   English   中英

我需要將圖像文件上傳並讀取到不屬於我的項目文件夾 Asp.NET MVC 5 的文件夾中。我的網站托管在 IIS 服務器中。 任何想法?

[英]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?

我需要將圖像文件上傳並讀取到不屬於我的項目文件夾的文件夾中。 我的網站托管在 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:\Whatever\folder\you\want", filename);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM