G
Guest
Hello World,
I am trying to replace a string in a large file without going through the
process of reading every line to locate the string in question. Is there a
function which will do this? I was looking into the FindReplace method of the
Find object, but couldn't find an example showing all the stuff that needs to
be added to the C++ code to use it.
In accordance with some sites on using DTE objects I've added the following
to my source file:
#pragma warning( disable : 4278 )
//The following #import imports DTE based on its LIBID
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0")
lcid("0") raw_interfaces_only named_guids
#pragma warning( default : 4278 )
using namespace EnvDTE; // optional
CComPtr<EnvDTE::_DTE> m_pDTE;
HRESULT hr = m_pDTE.CoCreateInstance("VisualStudio.DTE.7.1", 0, CLSCTX_ALL);
Find change;
change.FindReplace(vsFindAction.vsFindActionReplace,"<name>412<",NULL,"<Style>\n<iconstyle>\n<color>ff076aff</color>\n</iconstyle>\n</style>\n<name>412<",vsFindTarget.vsFindTargetFiles,KMLCounty,NULL,vsFindResultsLocation.vsFindResultsNone);
but when I try to compile the code I get errors like:
d:\data\dohertys\google earth\bridgedata\bridgedataDlg.cpp(180): error
C2039: 'vsFindResultsNone' : is not a member of 'System::Enum'
d:\data\dohertys\google earth\bridgedata\bridgedataDlg.cpp(170): error
C2259: 'EnvDTE::Find' : cannot instantiate abstract class
....
and lots of others
Does anyone have either some sample code to set this up, or an efficient
alternative?
Thanks,
Stephanie
I am trying to replace a string in a large file without going through the
process of reading every line to locate the string in question. Is there a
function which will do this? I was looking into the FindReplace method of the
Find object, but couldn't find an example showing all the stuff that needs to
be added to the C++ code to use it.
In accordance with some sites on using DTE objects I've added the following
to my source file:
#pragma warning( disable : 4278 )
//The following #import imports DTE based on its LIBID
#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0")
lcid("0") raw_interfaces_only named_guids
#pragma warning( default : 4278 )
using namespace EnvDTE; // optional
CComPtr<EnvDTE::_DTE> m_pDTE;
HRESULT hr = m_pDTE.CoCreateInstance("VisualStudio.DTE.7.1", 0, CLSCTX_ALL);
Find change;
change.FindReplace(vsFindAction.vsFindActionReplace,"<name>412<",NULL,"<Style>\n<iconstyle>\n<color>ff076aff</color>\n</iconstyle>\n</style>\n<name>412<",vsFindTarget.vsFindTargetFiles,KMLCounty,NULL,vsFindResultsLocation.vsFindResultsNone);
but when I try to compile the code I get errors like:
d:\data\dohertys\google earth\bridgedata\bridgedataDlg.cpp(180): error
C2039: 'vsFindResultsNone' : is not a member of 'System::Enum'
d:\data\dohertys\google earth\bridgedata\bridgedataDlg.cpp(170): error
C2259: 'EnvDTE::Find' : cannot instantiate abstract class
....
and lots of others
Does anyone have either some sample code to set this up, or an efficient
alternative?
Thanks,
Stephanie