In MVC c#. asp.net.
The requirement that I have is for the user to be able to select a directory and from there, as long as the files within the directory start with "Anqu" and are .pdf files, I need to upload all those files to a server.
Since there is not easy way to do a folder chooser, I thought what I would do is to have the user select a file from a folder and from there, I could retrieve the directory path and from thre I can retrieve all the files that fit the requirements.
This is the best approach that I found(please comment if you feel differently).
Once the user selects a file and hits submit, it goes to the following action result:
[HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file)
string dirName = new DirectoryInfo(file.FileName).Name;
to get the directory info. I am finding that it is not possible to get it.
This is what my view looks like:
@using (Html.BeginForm("FileUpload", "Plt", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" />
<input type="submit" value="OK" />
}