views:

173

answers:

2

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  A: 

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.

0xC0DEFACE
still not working.
shaimagz
+1  A: 

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.

sean e
I tried to do: doc.SaveFile("c:\myxml.xml");and its just saves the file with that name. I looked in tinyxml documentation and it says that this function get the file name. not a word about path. http://www.grinninglizard.com/tinyxmldocs/classTiXmlDocument.html
shaimagz
SaveFile is implemented via fopen_s (or fopen) - both of those work with full paths. It is not possible for the root name of a file to have a ':' in it. Why do you mean by it 'saves the file with that name'? Also, if you really are using '\', in your source it needs to be "\\". Alternatively, use '/'.
sean e
Thank you so much! the '\' was the problem.
shaimagz
cool. You might want to increase the compiler warning level. It will warn about unrecognized escape sequences (I don't think \m is a normal escape sequence).
sean e
it isnt, and i was about to suggest the same thing.
0xC0DEFACE