110,538
社区成员
发帖
与我相关
我的任务
分享
public void button7_Click(object sender, EventArgs e)
{
FolderBrowserDialog browse = new FolderBrowserDialog();
if (browse.ShowDialog() == DialogResult.OK)
{
this.textBox4.Text = browse.SelectedPath;
string[] texts1 = Directory.GetFiles(browse.SelectedPath, "*.txt", SearchOption.TopDirectoryOnly);//文件夹里所有文本文件
foreach (string file in texts1)
{
string[]texts2 = File.ReadAllLines(file, Encoding.Default);
}
int []file_num = new int[dictionary.Keys.Count]; //含有该词组的文件数
int flag = 0;
foreach(string word in dictionary.Keys)
{
file_num[flag] = 0;
for (int j=0; j < texts1.Length; j++)
{
if (texts2[j].Contains(word))
{
file_num[flag]++;
}
}