如何将这组pdf文件存储在集合中 [英] how can u store the set of pdf files in collections

查看:90
本文介绍了如何将这组pdf文件存储在集合中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将这组pdf文件存储在数组列表中的集合中,列表



实际上我的probelm是存储在filearray中的pdf文件路径集,也是文件



文件数组的名称,大小,长度,但文件内容未正确读取,这就是我想要的原因



存储集合上的pdf文件



我的文件阵列代码:



how can u store the set of pdf files in collections like array list,list

actually my probelm is set of pdf files path stored in filearray and also get the file

name,size,length from file array but file content not read properly thats why i want to

store set of pdf files on collection

my filearray code:

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;

        }
        }
    }





请帮我



pls help me

推荐答案

您无法以这种方式阅读PDF文件并希望了解其内容。转到 http://www.adobe.com/products/acrobat/adobepdf.html [ ^ ]来研究PDF文件的结构。还有各种有助于阅读内容的第三方库,例如 http://sourceforge.net/projects/itextsharp/ [ ^ ]。
You cannot read PDF files in that way and expect to understand their content. Go to http://www.adobe.com/products/acrobat/adobepdf.html[^] to study the structure of PDF files. There are also various third-party libraries that help to read the content, such as http://sourceforge.net/projects/itextsharp/[^].


这篇关于如何将这组pdf文件存储在集合中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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