I have a Visual Studio 2008 addin that when I press a certain hotkey, it opens a specific file (different based on the context of the hotkey) and then searches that file for a specific string (again, context dependent.) Most of the time this works flawlessly, but sometimes if the file it's opening is too big, the search will fail.
Here is a code snippet:
Window xmlWindow = Commands.Application.ItemOperations.OpenFile(objectFilename, EnvDTE.Constants.vsViewKindPrimary);
Find find = xmlWindow.Document.DTE.Find;
find.Action = vsFindAction.vsFindActionFind;
find.FindWhat = String.Format("Name=\"{0}\"", objectLocalName);
if (find.Execute() == vsFindResult.vsFindResultFound) {
MessageBox.Show("Found!");
}
1. Is there a way to get it to always work (for example by blocking on the OpenFile)?
2. On a less important note, is there a way to search like this without having the results end up in the Find Results pane (this causes my old results to be cleared out by this search that is only used to get the cursor down to that part of the file)?
Thanks!