question

KIRANKUMARGUNTI-3906 avatar image
0 Votes"
KIRANKUMARGUNTI-3906 asked YijingSun-MSFT answered

Open Folder Dialog Box

Hi,

I want to Open Folder Dialog box in MVC web application in Controller code.

please help.

Thanks

dotnet-aspnet-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @KIRANKUMARGUNTI-3906 ,
Do you means fileupload? You could use Fileupload control.

  @Html.EditorFor(model => model.ImagePath, new { htmlAttributes = new { @class = "form-control" } })  
     @Html.ValidationMessageFor(model => model.ImagePath, "", new { @class = "text-danger" })  
 @using(Html.BeginForm("ContactForm", "Home", FormMethod.Post, new  
 {  
     enctype = "multipart/form-data"  
 }))  
   

 [HttpPost]  
 public ActionResult ContactForm(MemberModel membervalues)  
 {  
     //Use Namespace called :  System.IO  
     string FileName = Path.GetFileNameWithoutExtension(membervalues.ImageFile.FileName);  
      
     //To Get File Extension  
     string FileExtension = Path.GetExtension(membervalues.ImageFile.FileName);  
      
     //Add Current Date To Attached File Name  
     FileName = DateTime.Now.ToString("yyyyMMdd")+"-"+FileName.Trim()+ FileExtension;  
      
     //Get Upload path from Web.Config file AppSettings.  
     string UploadPath = ConfigurationManager.AppSettings["UserImagePath"].ToString();  
      
     //Its Create complete path to store in server.  
     membervalues.ImagePath = UploadPath + FileName;  
      
     //To copy and save file into server.  
     membervalues.ImageFile.SaveAs(membervalues.ImagePath);  
      
     return View();  
 }  

More details,you could refer to below article:
https://www.c-sharpcorner.com/article/asp-net-mvc-form-with-file-upload/
Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.