I want to Browse folder and show selected folder path in Textbox. I have used FolderBrowserDialog ,but it is not working in Asp.Net Web Application. Also FolderBrowseDialog window appear in back.
I there any alternative to FolderBrowserDialog in web forms?
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK)
{
selectedFilePath.Text = fbd.SelectedPath;
filePath = fbd.SelectedPath;
filePath = filePath.Replace(@"\\", @"\");
}
}
Ok, when you say browse to some folder? I would have to "guess" that you mean say a particular folder and location. I kind of doubt that you would want (or let) anyone on the web site to go browsing around on that web server and the network it is attached to? Seems a little too high risk, right?
In fact, probably better is to say pull the list of files from that folder - maybe my up-loads folder or whatever.
You can then display/present a list of files to the user - in a grid view for eaxample. And thus for each row, say a download button.
Now, if for some reason that folder had many sub folders? then present the user with maybe a tree view control. but, the concept of have a web server, and the users browser (sitting on each users desktop) to browse and rummage around on the files on the server? Sounds WAY WAY too high risk, and far too dangerous from a security point of view.
However, as noted, you can certainly pull/build/create a "list" of files that exist in a folder on the server, present that list of files, and let the user then download such files.
so, say in our web site, we have a folder ~/Content/Animals/
So, drop in a grid view to the page like this:
And code behind to load is thus this:
And when we run, we now get/have this:
And the code behind the down load button, is this:
So, you are free to load up a grid. And as noted, if you needed to allow user to select/show/have say sub folders. Then in place of the gridView, use a tree view.
So, it kind of depends on what kind of list of files you wish to present to the user.