user1471194
user1471194

Reputation: 23

I need to get the folder path,how to select a folder using fileupload in asp.net?

I want to select the folder using the file upload control and i need to just get the folder path that is to be saved.I think it is not possible to select a folder using file upload control but i think it is possible by some kind of customization. Please anyone could help me.

Upvotes: 1

Views: 5104

Answers (4)

BOBIN JOSEPH
BOBIN JOSEPH

Reputation: 1022

Use the following code to select the folder in asp.net

<asp:FileUpload ID="FileUpload1" runat="server" webkitdirectory directory multiple />

Upvotes: 0

waseem
waseem

Reputation: 11

to select multiple file file upload property Allow Multiple="True,False"

Upvotes: 1

R.C
R.C

Reputation: 10565

FileUpload control can upload a single file only at a time which then takes the Full file path.

At first, One solution ( which doesn't seems feasible at all) comes in mind is to use multiple FileUpload controls, but definitely the question is: different folders can have a varying number of files, so what number of FileUpload controls to use.[ Of course, there can be many other reasons too for avoiding this solution. ]

So far to make sure we upload all files of a folder in one go, is to create a custom User Control which allows to select multiple files and upload them in one go.

Check this article on achieving the same. This another Link2 may be helpful too.

Upvotes: 1

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

I think you need to file path without file name . here you can get just path not name !

string[] Dir = FileUpload1.FileName.Split('\\');
            string Path="";
            for (int i = 0; i < Dir.Length; i++)
                Path += Dir[i] + "\\";

after this you can use Path for folder path!

Upvotes: 1

Related Questions