从目录中获取文件时如何排除某些文件类型?
我试过了
var files = Directory.GetFiles(jobDir);
Run Code Online (Sandbox Code Playgroud)
但似乎此功能只能选择要包含的文件类型,而不能排除.
我想设计一个包含浏览按钮的程序,我们可以浏览到所选文件夹并打开文件夹内的文件.
我需要一个参考和阅读,我可以解决我的问题?喜欢我应该使用什么方法/类.我不喜欢从MSDN上读书,因为我很难理解他们的理论.仅供参考我仍然是C#的初学者.
非常感谢你
P/s:这是我从互联网上找到的代码,您可以浏览/创建新文件夹.但我不知道为什么它使用Shell32.dll ..
private void button1_Click(object sender, EventArgs e)
{
string strPath;
string strCaption = "Select a Directory and folder.";
DialogResult dlgResult;
Shell32.ShellClass shl = new Shell32.ShellClass();
Shell32.Folder2 fld = (Shell32.Folder2)shl.BrowseForFolder(0, strCaption, 0,
System.Reflection.Missing.Value);
if (fld == null)
{
dlgResult = DialogResult.Cancel;
}
else
{
strPath = fld.Self.Path;
dlgResult = DialogResult.OK;
}
}
Run Code Online (Sandbox Code Playgroud)