Actually i have develop winform app for pdf files detailes and bind to the gridview
i have read the content of pdf file and pdffullname(path of filename) but i want to how
to read filename(not path of file),size,extension of files and problem the binding the
gridview .i had binded the fullname of file using list collection to the gridview but
gridview shows the length attribute only .finally i want pdfdetailes(filename,size,length) and
slove the binding problem.
my developed code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.IO;
using form_app.Lib;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace form_app
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string ExtractTextFromPdf(string filename)
{
using (PdfReader r = new PdfReader(filename))
{
StringBuilder text = new StringBuilder();
for (int i = 1; i <= r.NumberOfPages; i++)
{
text.Append(PdfTextExtractor.GetTextFromPage(r, i));
}
return text.ToString();
};
}
private void button1_Click(object sender, EventArgs e)
{
List<string> filelist = new List<string>();
string pathName = @"D:\Data Sets\Enron";
string[] pdfFileNames = Directory.GetFiles(pathName, "*.pdf");
MessageBox.Show(pdfFileNames.Length.ToString());
foreach (string pdfFileName in pdfFileNames)
{
fileproperties fi = new fileproperties ();
fi.fullname = pdfFileName;
fi.content = ExtractTextFromPdf(pdfFileName);
filelist.Add(fi.fullname);
}
dataGridView1.DataSource = filelist;
}
}
}
fileproperties.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace form_app.Lib
{
class fileproperties
{
public long filesize { get; set; }
public string filename { get; set; }
public string fullname { get; set; }
public string extension { get; set; }
public string content { get; set; }
}
}
pls help me.