I'm working on search function for my self-made Windows Explorer. I use Directory.GetFiles(string path, string searchPattern, searchOption searchOption)
to do that. My problem is that when I call:
string searchPattern = '"' + searchBox.Text + '"'; // searchPattern = "duck"
string path = @"D:\test";
string[] searchResults = Directory.GetFiles(path, searchPattern, System.IO.SearchOption.AllDirectories);
It throws the exception:
"Illegal characters in path."
This is the file structure:
D:\
---test\ (Folder)
-------duck.txt (File)