tags:

views:

44

answers:

3

I have an application that uses an .xml file to load information about objects (Such as strings for name, location etc.. nothing too complicated).

Currently when i use the application the .xml file is stored in:

"/bin/debug" 

of my project folder.

If i was to release my application as a standalone .exe how would i go about ensuring the .xml is at a suitable location? For example the application creates the settings file on the Desktop by default but they decide to keep the application .exe in Documents.

What would be the best way to tackle this? Is there any way to save the .xml information to the application itself to remove the need for the .xml in the first place?

Hopefully i've given enough information

Thanks

+1  A: 

Do the contents of the XML file have to be changed after deployment? If so, I would simply include the xml in your config file, as application settings.

If not, consider using a resource file.

Gerrie Schenck
My application allows the user to create a new "template", that is an object that stores a string for a file location and name". This is used in addition to the templates I have already included in the application itself through code.If the user makes a new template then it needs to be persistant so it will be available when the user loads the application at a later date.This can be changed though, if the name is incorrect for example then i give the user the option to change the information.
Jamie Keeling
Then settings are what you need. Check out this article to get started: http://msdn.microsoft.com/en-us/library/aa730869%28VS.80%29.aspx
Gerrie Schenck
Excellent, thanks for the help.
Jamie Keeling
A: 

Have you looked into serializing the xml you are working with to an object?

Here is an example of what I am talking about:

http://msdn.microsoft.com/en-us/library/ms973902.aspx

Burt
+1  A: 

@Jamie, beware of keeping settings files disjunct from the application installation or locations such as ApplicationData/AppName. Keeping them on the desktop or in "random" storage places may allow your user to be forgetful and remove these files unwantingly.

I suggest app specific settings stay with the application or in a single central location and any user specific settings be stored in ApplicationData/AppName (ApplicationData and other Windows locations are available through Environment.GetFolderPath(Environment.SpecialFolder.xxxx) where "xxxx" is the Windows defined folder.

Jamie Altizer
I used the Desktop location as an example but i understand your point, I've never needed persistent data in any of my other applications so this is a bit new to me.
Jamie Keeling