如何在目录中搜索多个PDF文件以查找特定的“作者”名称,如果找到该文件,如何获得该文件的路径?目前,我正在使用EnumerateFiles
浏览目录,然后循环使用PDfReader
显示每个PDF文件中的所有作者姓名。我只是不知道现在该如何搜索那个具体的作者名字。
我的代码如下:
path = @"C:\Users\thomas\Desktop\PDFfiles";
var files = Directory.EnumerateFiles(path, "*.pdf", SearchOption.AllDirectories);
foreach (string currentFile in files)
{
PdfReader reader = new PdfReader(currentFile);
string authorName = reader.Info["Author"];
listBox1.Items.Add("Author is: " + authorName);
}
我在我的ListBox
中得到了作者名字的列表,但是我如何在所有的PDF文件中搜索特定的名字呢?
谢谢
发布于 2016-08-24 22:46:08
您可能需要使用新列表来保存所选作者的结果,如:newList = listBox1.Items.Where(x => x.Text == authorName);
https://stackoverflow.com/questions/39132235
复制相似问题