예제 #1
0
        private void Ofd_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                List <PdfFileInfo> files = new List <PdfFileInfo>();

                BinaryReader r = new BinaryReader(File.OpenRead(ofd.FileName));

                int count = r.ReadInt32();

                while (count-- > 0)
                {
                    PdfFileInfo info = new PdfFileInfo();
                    info.Path              = r.ReadString();
                    info.FileName          = r.ReadString();
                    info.Size              = r.ReadString();
                    info.Content           = r.ReadString();
                    info.IndexedCharacters = info.Content.Length.ToString();

                    files.Add(info);
                }

                r.Close();

                Files = files;

                Filter();

                ShowInfo("Loaded Index");
            }
            catch
            {
                ShowInfo("Could not read File");
            }
        }
예제 #2
0
        private void CreateIndex(string path)
        {
            Files.Clear();

            string[] files = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories);

            foreach (string file in files)
            {
                FileInfo fi = new FileInfo(file);

                PdfFileInfo info = new PdfFileInfo();

                info.Path     = file;
                info.FileName = fi.Name;
                info.Size     = $"{fi.Length /1024}k";

                try
                {
                    using (var pdfStream = File.OpenRead(file))
                        using (var extractor = new Extractor())
                        {
                            info.Content           = extractor.ExtractToString(pdfStream).ToLower();
                            info.IndexedCharacters = info.Content.Length.ToString();
                            Files.Add(info);
                        }
                }
                catch { }
            }
        }
예제 #3
0
        private void listView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            PdfFileInfo i = listView.SelectedItem as PdfFileInfo;

            if (i != null)
            {
                System.Diagnostics.Process.Start(i.Path);
            }
        }