using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO; using System.Collections; using System.Windows.Forms; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public static string StringFromBytes(byte[] arr) { char[] ch = new char[arr.Length / 2]; for (int i = 0; i < ch.Length; ++i) { ch[i] = (char)((int)arr[i * 2] + (((int)arr[i * 2 + 1]) << 8)); } return new String(ch); } private void button1_Click(object sender, EventArgs e) { ArrayList fileStatistics = new ArrayList(); String datasetPath = @"D:\Data Sets\Enron"; DirectoryInfo d = new DirectoryInfo(datasetPath); FileInfo[] files = d.GetFiles("*.pdf"); MessageBox.Show(files.Length.ToString()); foreach (FileInfo file in files) { //create instance of data class fileAtt f = new fileAtt(); f.fFullName = file.FullName; f.fName = file.Name; f.FileSize = file.Length; f.fExtension = file.Extension; byte[] bytes = File.ReadAllBytes(file.FullName); f.content =Form1.StringFromBytes(bytes); //f.content = Encoding.ASCII.GetString(bytes); f.lastaccesstime = file.LastAccessTime; fileStatistics.Add(f); // StreamReader r = new StreamReader(datasetPath); //foreach } gvStatistics.DataSource = fileStatistics; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)