3
I want to take a system directory, open a window and in that window I select a directory. I can select files with the OpenFileDialog
but directories do not.
3
I want to take a system directory, open a window and in that window I select a directory. I can select files with the OpenFileDialog
but directories do not.
3
You can use the class FolderBrowserDialog
:
// Instancia a classe.
using (FolderBrowserDialog dirDialog = new FolderBrowserDialog())
{
// Mostra a janela de escolha do directorio
DialogResult res = dirDialog.ShowDialog();
if (res == DialogResult.OK)
{
// Como o utilizador carregou no OK, o directorio escolhido pode ser acedido da seguinte forma:
string directorio = dirDialog.SelectedPath;
}
else
{
// Caso o utilizador tenha cancelado
// ...
}
}
In addition to the basic use, you can also allow the user to create directories through the window. To do this, set the following property to true
:
dirDialog.ShowNewFolderButton = true;
You can also decide which directory to choose when the window is open. To do this use the property FolderBrowserDialog.RootFolder
.
1
Instead of using Openfiledialog use control folderBrowserDialog
Source
http://msdn.microsoft.com/en-us/library/aa984305%28v=vs.71%29.aspx
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.