Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

C#
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.
Posted
Comments
[no name] 29-Jan-15 20:41pm    
OK the code does not do what you think it should. Have you used the debugger?
Krishna Veni 29-Jan-15 21:00pm    
ya.i have traced out the content of files using break points but i didn't get that filenames.i want that file names
Dave Kreskowiak 29-Jan-15 21:20pm    
What EXACTLY is the problem? Are you getting the list of filenames and can't get the content or are you not getting the list of filenames?
Krishna Veni 29-Jan-15 21:24pm    
I am getting content of files but i didn't get the filenames.

i want list of filenames.
[no name] 29-Jan-15 21:48pm    
Does not make sense.

1 solution

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

just print or display them
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900