I have a project that will require merging multiple snippets of text together. There will be a record of multiple snippets of text, that depending what boxes a user ticks, will be merged in to a single output file.
I suppose you could imagine it as each snippet is a sentence of text that has one or more tags. as then if the user clicked on tag name in the application it would pull out all sentences with that tag in to an array/list.
What is the best way to achieve this?
-
I need the users to be able to add new snippets as they go and to be
stored when the application is shut down. -
Must be easy to copy all the snippets from one instance of the
application to another, ideally simply copying a folder, or single
file to export/import. -
It may have more than 500 snippets of code, each a few hundred lines long. So I’m not sure simply storing each item as a text file would work or
would not slow down the application too much. -
I don’t want a centralized db server. It needs to work completely stand-alone as I can’t guarantee the user would have network access.
-
If it uses a Database needs it to be contained within the app. I don’t want the
user to need to install a 3rd party app or DB server to use the tool.
So how do I go about storing this in a DB and how can I make the date exportable between separate instances?
I am sure that I could work together my own DB code, but I am sure that would be horrendous and slow. Is there a standard method that I should be looking at. Don’t need to know how to do it. I just want some ideas to look at before I run of down the wrong path.
You might want to look at something like SQL Compact for your database – it is zero installation, all you have to do is ship a couple of dlls with your application. Here is a good tutorial from Scott guthrie on how to use it with your application.
There are also a number of other small “embedded” style database management engines out there, but that may be overkill depending on the amount of data you are storing. Alternatively you could store your text snippets in a local XML file, and use LINQ to XML to manage it. (Starter article: LINQ to XML – 5 Minute Overview).