Question C# to VB.NET for IFilter

GoodJuJu

Member
Joined
Apr 26, 2010
Messages
24
Location
England
Programming Experience
5-10
Hi there, I am new to this site and also new to C# and VB.NET.

I am proficient in Visual Basic, but I think I need to use .net and move with the times to achieve what I want.

I am trying to write an application which extracts text from documents (.doc, .pdf, .xls etc. etc) using IFilter.

I have found a very good example application in C# (Using IFilter in C# - CodeProject) which does what I want, but I am really struggling with C#

Does anybody know if there is a way to achieve the same results (i.e. extracting text from documents using IFilter) in VB?

I have found a few examples on the web which do not seem to explain much - most examples I see are in C#. I would love to be able to just learn C# and make it work, but the reality is I really need to use VB as I am just more comfortable with it.

Any help anyone can offer is much appreciated.

Thanks.
 
Why do you need to convert the code? You can use the download from that article, add reference to EPocalipse.IFilter.dll library and use it from your VB.Net project:
VB.NET:
Using reader As New EPocalipse.IFilter.FilterReader("filename")
    TextBox1.Text = reader.ReadToEnd()
End Using
 
Thanks, but do I also need to reference the classes?

JohnH,

Thanks very much for your response.

Excuse my ignorance please. Would I also need to reference the classes from the C# project, or are these bundled in the .dll already?

Thank you.
 
JohnH, you're a genius!!! It works!! I guess the classes get 'wrapped' in the .dll

Thank you very much for your suggestion.

It even 'spews' the error out of the dll if it encounters one which I can handle inside of my code.

I appreciate your help.
 
Problems with code

Hi

If I run the sample C# code it works fine and extracts text from docs, pdf, etc.

I converted it to run in VB.net using the following code

Imports System.IO




Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim d As New OpenFileDialog
d.Filter = "All Files|*.*"
If d.ShowDialog() = DialogResult.OK Then


Dim reader As TextReader = New EPocalipse.IFilter.FilterReader(d.FileName)
Using reader
TextBox1.Text = reader.ReadToEnd()
End Using


End If
End Sub



End Class

It works for doc files, but every time I try and open a pdf file I get a "NotImplementedException" error?

My first though was that I dont have the ifilter for pdf, but it works in c#

Any ideas?

Thanks

Zyb
 
Fixed it

Hi

Fixed it.

I had downloaded a 64 bit version of the PDF ifilter during my tests, and the app was compiled as 32 bit. Forced it to compile as 64 bit and it worked.

Zyb
 
Back
Top