i have develop winform app for accessing pdf properties like filename and full path of
file,size,extension,content of pdf file.alredy i am accessing path of file and content
of pdf file then i want remaing properties like filename,size,extension
Important:File class is useful for fileinfoarray but i am not using fileinfo array i
am using string array only.pls don't tell to use File class.it is not useful for filname,size,extensions.File class have no method for access extension,filename,size.if any
approaches will be there tell me.
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 System.IO;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.Windows.Forms;
using pdf_app.Lib;
namespace pdf_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)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.CheckFileExists = true;
openFileDialog.AddExtension = true;
openFileDialog.Multiselect = true;
openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
DialogResult result = openFileDialog.ShowDialog();
if (result == DialogResult.OK)
{
string[] files = openFileDialog.FileNames;
}
foreach (string access in openFileDialog.FileNames)
{
fileatt f = new fileatt();
f.fFullName = access;
f.fContent = ExtractTextFromPdf(access);
}
}
fileatt class like :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pdf_app.Lib
{
class fileatt
{
public long FileSize { get; set; }
public string fName { get; set; }
public string fFullName { get; set; }
public string fExtension { get; set; }
public string fContent { get; set; }
}
}
i want remaing properties like filename,size,extension
pls help me.