我想在c#中阅读pdf文件名 [英] i want to read pdf filenames in c#

查看:77
本文介绍了我想在c#中阅读pdf文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我已经开发了一个winform应用程序。这个应用程序访问文件内容



但是没有访问那个文件名。我想在c#accroding中访问pdf文件名到我的



开发代码。



我的代码如:



Actually i have develop one winform application.this application access content of files

but didn't access that filenames.i want to access pdf filenames in c# accroding to my

developed code.

my code like as:

public static string ExtractTextFromPdf(string filename)
       {
           using (PdfReader reader = new PdfReader(filename))
           {
               StringBuilder text = new StringBuilder();

               for (int i = 1; i <= reader.NumberOfPages; i++)
               {
                   text.Append(PdfTextExtractor.GetTextFromPage(reader,i));
                   //text.Append(PdfTextExtractor.GetTextFromPage(reader,i));
               }
               return text.ToString();
           }
       }
       private void button1_Click(object sender, EventArgs e)
       {
           string pathName = @"D:\Data Sets\Enron";

           string[] pdfFileNames = Directory.GetFiles(pathName, "*.pdf");

           foreach (string pdfFileName in pdfFileNames)
           {
               DocumentVector d1 = new DocumentVector();
               d1.content= ExtractTextFromPdf(pdfFileName);
               docCollection.DocumentList.Add(d1.content);

           }

           MessageBox.Show(pdfFileNames.Length.ToString());

       }





请尽快帮助我。谢谢你。



pls help me as soon as possible.thank u.

推荐答案

你已经在这里找到了这个列表:

you got the list here already:
string[] pdfFileNames = Directory.GetFiles(pathName, "*.pdf");



只需打印或显示它们


just print or display them


这篇关于我想在c#中阅读pdf文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆