|
-
Sep 4th, 2010, 02:48 PM
#1
Where to store config files

I'm writing an application that will be used to generate reports from a database and I want to have several predefined reports/queries built in but also offer the user the option to create their own query and be able to save it and run it whenever they want without having to set the query up again each time.
So I figured I would just store the query parameters in an XML file for the ones that a user has created themselves and I would store these XML files (one for each query) in the user's Application Data folder.
I'm wondering what I should do with the built in queries though (bear in mind that the parameters of these built in queries should not be configurable). As I see it, these are my options:
1. Have the query parameters hard coded in the application
2. Store the query parameters in XML files in the location where the app is stored (ie Program Files) - the installer would create these files when the app is installed
3. Store the query parameters in XML files in the user's Application Data folder with any queries they have created themselves.
I'm leaning towards option 2 for the following reasons: All queries (user defined or predefined) would then be in the exact same format and the program could then run them all in the exact same way. Option 1 would mean I would have to release a new version of the application if I ever wanted to change these parameters. Option 3 would mean that the program would have to create the XML files each time it was launched by a new user so it would be a bit pointless and the values for the parameters would still have to be hard coded in the application so that it could create the files correctly.
What do you guys think?
Cheers
Chris
-
Sep 4th, 2010, 09:46 PM
#2
Re: Where to store config files
For option 1, you would most likely embed the XML files as resources. That would then allow you to extract the appropriate resource and then use it basically the same way as a user file. This option is the best unless you consider deploying a new version of the app when these resources change an issue.
If that is an issue, option 2 is the best option. These files are supposed to be read-only so there's no issue with write permissions for restricted users. The only issue is how to deploy the files if they change. Will an admin simply copy the files into the folder manually? That's a little bit messy but OK if the admins are OK with it.
As stated, option 3 is not an option at all. If you were to use the application data folder then you'd use the common folder, not the user's folder. That way you have one copy for all users. The application data folder is supposed to be for read/write files though, so I'd avoid that unless you want restricted users to be able to replace the files when new versions are released, which doesn't really sound like a good idea.
-
Sep 5th, 2010, 08:18 AM
#3
Re: Where to store config files
Thanks, I hadn't thought about including the XML files as resources - if I were to do that though, wouldn't I have to extract the resource to a physical file location before I could read them with XmlDocument or XmlReader etc? If so then I guess I would have to extract them to the user's app data folder but then I've got to do that for every new user that uses the application and it seems a bit daft when there only needs to be one copy.
As for option 2 - this application is aimed at IT system admins, so to be honest 90% of the users would probably have local admin permissions anyway. Of course I dont want to take that for granted and have my application write to Program Files because that's just bad design anyway, plus it would fail if the user wasn't a local admin. So I think most users would be fine with just copying XML files into the folder if they needed to.
To be honest I cant see me ever really needing to update these files but I just thought if I do then it would be nice to have the option of users manually editing or replacing the XML files rather than having to download and install a new version of the app.
-
Sep 5th, 2010, 09:20 AM
#4
Re: Where to store config files
Maybe the base query that you deploy is done as a resource. If the user then makes changes, or what ever, that would get saved in the user's app data folder (or the common app data folder). At least that's probably how I'd do it.
-tg
-
Sep 5th, 2010, 09:42 AM
#5
Re: Where to store config files
Can you explain exactly what you mean by "done as a resource" ?
-
Sep 5th, 2010, 09:45 AM
#6
Re: Where to store config files
Store the query as a resource... Option 1 as jmc noted.
-tg
-
Sep 5th, 2010, 10:49 AM
#7
Re: Where to store config files
So if I store an XML file for each of the built in queries as a resource in my app, do I need to write them out to file before I can use them? If I do then I don't see any point in having them as a resource... I may as well just have the installer create the files when the app is installed.
-
Sep 5th, 2010, 06:43 PM
#8
Re: Where to store config files
When you get a resource using My.Resources, the type it returns depends on the type of the original data. In the case of an XML file, I think you'll find that My.Resources returns and XmlElement or an XElement or something like that. Basically the same as you'd get using an XML literal. You should be able to use that data in code, just as you would the data from an XML file that you opened and read.
If you need a file to pass to some other process or the like then using a resource still provides the advantage that the user can never delete or edit the original data, because that's safely compiled into the executable.
-
Sep 6th, 2010, 05:17 AM
#9
Re: Where to store config files
Ah ok cool, if it just returns an XmlDocument or something then that sounds like a good solution I'll have a play around with it, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|