[英]Select html files in a folder
Using "folderBrowserDialog1" can i select only HTML files in a folder. 我可以使用“ folderBrowserDialog1”仅选择文件夹中的HTML文件。
My code is like this : 我的代码是这样的:
private void btnBrowse_Click(object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
}
}
Use: DirectoryInfo.GetFiles Method (String) 使用: DirectoryInfo.GetFiles方法(字符串)
Returns a file list from the current directory matching the given search pattern.
从当前目录返回与给定搜索模式匹配的文件列表。
string[] files = Directory.GetFiles("*.html");
Or if you only want to html
files to be available for selection you can use: 或者,如果您只希望
html
文件可供选择,则可以使用:
folderBrowserDialog1.Filter = "*.html | *.htm";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.