Last post Mar 21, 2011 07:14 AM by heldersantos.moreira
Mar 04, 2011 06:04 AM|heldersantos.moreira|LINK
I have a .doc file which is stored in my database as a binary file. Is there any way i can search for a word using the binary file?
Imagine i have my 100 binary files in my database, and i want to search them all to know which of them contain the word "HELLO". How should i do this?
Mar 04, 2011 07:57 AM|duttavr|LINK
I did this one of my requirement. But first parameter of GetSelectedResumes expects filenames which are in phsycal path. I'm just thinking how to use Word.Application.Open method to pass FileStreme Object. It does not have any overloaded method to receive
If you would like to use this approch, you need to add reference to Microsoft.interop.office.excel.dll and read your binary stream and save it in disk use following search method then delete it. This is bit unfair. Need to investigate how to pass FileStrem
object to Word.Application.Open().
private List<String> GetSelectedResumes(IEnumerable<string> fileList, List<string> selectedSearchTexts)
List<String> selectedResumes = new List<string>();
foreach (var filePath in fileList)
bool isSelected = SelectResume(filePath, selectedSearchTexts);
private bool SelectResume(string filePath, List<string> searchList)
Word.Application app = new Word.Application();
Word.Document document = app.Documents.Open(filePath, ReadOnly: true);
bool isResumeSelected = true;
foreach (var searchText in searchList)
bool isFound = FindText(document.StoryRanges, searchText);
isResumeSelected = false;
private bool FindText(Word.StoryRanges storyRanges, String searchText)
foreach (Word.Range range in storyRanges)
bool result = range.Find.Execute(searchText);
Mar 05, 2011 12:38 PM|heldersantos.moreira|LINK
Mar 05, 2011 08:03 PM|duttavr|LINK
You might want to think converting to text files and use normal file streams, but to convert to text format we need word API.
I'm wondering how this can be done without word api.
Mar 07, 2011 04:21 AM|heldersantos.moreira|LINK
Exactly, that was my doubt also. Do you think that there's any way to convert to text without the Word API?
Mar 21, 2011 07:14 AM|heldersantos.moreira|LINK
Well, for future reference i have to say that i have kind of given up on this task. It is possible if done with an API (MS Word or not, Aspose is very good also) but that wasn't my objective (converting every file and analyze it). It may also be possible
by making a parser using the specifications that Microsoft has released about Office and its encoding. This option involves a lot of work and i wanted a simpler solution, so at least for now, this is on stand by.