'Folder browser asp.net website
Is there any way I can get a file explorer to open up and allow the user to choose a folder destination in a website ? I want to then save this location and this will be the location for uploads.
Solution 1:[1]
Solution 2:[2]
Use the following code. Its working for me.
protected void browse_Click(object sender, EventArgs e) {
Thread thdSyncRead = new Thread(new ThreadStart(openfolder));
thdSyncRead.SetApartmentState(ApartmentState.STA);
thdSyncRead.Start();
}
public void openfolder()
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
DialogResult result = fbd.ShowDialog();
string selectedfolder = fbd.SelectedPath;
string[] files = Directory.GetFiles(fbd.SelectedPath);
System.Windows.Forms.MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | zey |
| Solution 2 | John Saunders |
