Visual Studio 2005 and Tinyxml - xml file location

2019-09-06 12:13发布

问题:

For some reason my Tinyxml file which is created via visual studio 2005 (c++) is saved on my desktop instead of the debug folder or in the program's root folder.

if anyone knows about some way to tell vs2005 to save the tinyxml create file somewhere else?

I tried that with eclipse and it saved the file in the program's root folder, which is what I'm trying to do.

thanks.

EDIT: I'm doing a BHO (Browser Helper Object), this is an add-on Internet Explorer. so when I run my program the 'exe' is iexplore.exe from c:\program files\Intenet Explorer

回答1:

You normally shouldn't aspire to write data files to your program directory. Rather than leaving the output directory to chance, you should explicitly tell TinyXml where you want the file created by passing in the whole path when you call SaveFile.



回答2:

Make sure you have set the working directory to $(OutDir) in "Project Properties->Debugging"

and then just call:

TiXmlDocument tiXmlDocument;
tiXmlDocument.SaveFile( "bleh.xml" );

That file should then be in the same directory as your exe.

Edit: If its an add on to internet explorer than I don't know where the working directory would be, but im sure there would be some environment variable or something provided by internet explorer that would give you a temp directory or something.