伙计们,正如标题所说,我必须获取具有特定(用户指示)子字符串的文件夹名称。
我有一个文本框,用户将在其中输入想要的子字符串。我正在使用下面的代码来实现我的目标。
string name = txtNameSubstring.Text;
string[] allFiles = System.IO.Directory.GetFiles("C:\\Temp");//Change path to yours
foreach (string file in allFiles)
{
if (file.Contains(name))
{
cblFolderSelect.Items.Add(allFiles);
// MessageBox.Show("Match Found : " + file);
}
else
{
MessageBox.Show("No files found");
}
}
这没用。当我触发它时,只出现消息框。帮助 ?