I am trying to search folder, those are placed in my local drive by using ComboBox
just like Google suggestions. All goes well but by default it searches .sys
files. I am wondering is there any extension of folder is available ? .
Or any other idea to search whole folder in combo box by using C# WPF ?
public FileInfo[] MyCollection { get; set; }
public MainWindow()
{
try
{
var di = new DirectoryInfo("c:\\");
MyCollection = di.GetFiles();
InitializeComponent();
DataContext = this;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
There are a few things that you will need to change then
Change your collection to
public DirectoryInfo[] MyCollection { get; set; }
and then the fetch to
MyCollection = di.GetDirectories();
This will give you a list of folders (or directories) instead of the list of files.
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.