简体   繁体   中英

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.

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!

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.

选择多个文件文件上传属性Allow Multiple =“True,False”

使用以下代码在asp.net中选择文件夹

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

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