private void AutoComplete()
{
string path;
string pattern;
string[] matches;
bool rooted = true;
if (Text == string.Empty || Text.IndexOfAny(new char[] { '?', '*' }) != -1) return;
path = Path.GetDirectoryName(Text);
pattern = Path.GetFileName(Text);
if (path == null || path == string.Empty && ShellView != null && ShellView.CurrentFolder.IsFileSystem && ShellView.CurrentFolder.ParsingName != ShellItem.Desktop.ParsingName)
{
path = ShellView.CurrentFolder.FileSystemPath;
pattern = Text;
rooted = false;
}
matches = Directory.GetFiles(path, pattern + '*');
for (int n = 0; n < 2; ++n)
{
if (matches.Length > 0)
{
int currentLength = Text.Length;
Text = rooted ? matches[0] : Path.GetFileName(matches[0]);
SelectionStart = currentLength;
SelectionLength = Text.Length;
break;
}
else
{
matches = Directory.GetDirectories(path, pattern + '*');
}
}
}