Is it possible to add, edit, view and delete records using a file only (instead of a database) and .Net 2005 (VB.Net/C#)?
The concept is that a file that'll work more-or-less like a database. One can add, edit, view, delete and query data to and from the file. The file, either cannot be opened directly or data inside the file should be in some encrypted form so that even if the file is opened no one can comprehend it. Data inside the file can only be manipulated by a front end application i.e. .Net 2005.
If there's some methodology like this then please refer me some links to tutorials and whitepapers. Thanks in advance.
Loading
Sam HobbsPosted Jan 31, 2010, 12:48 PM
One thing about your question is not clear to me; are you able to design the format of the disk file or is there a format that already exists that you must write a program to access and use?
.Net and Visual Studio support use of Objects for data, and you can create data sources from objects. That way, you can store the data on disk in may ways. There are various ways to store data on disk; look for articles and documentation about serializing data and about persistence. For example, the MSDN has an article called "Walkthrough: Persisting an Object in Visual Basic". There are many other articles on the subject. Also .Net has many cryptographic classes. I think what you can do is to persist objects (class instances) to stream, then encrypt that data and then store that to disk as binary data. To reverse that, read the binary data into memroy, then decrypt that, then un-persiste it back to objects. Another option is to store the data using XML and use the EncryptedXml and related classes. It is possible to use the XmlSerializer class and the EncryptedXml and related classes together.
Sam HobbsPosted Feb 3, 2010, 12:40 PM
Please see How to access fields and values from an XML Database; it has some sample code from me that shows use of XmlSerializer.
Next look at the documentation of the EncryptedXml class. There is a sample there. The sample can be intimidating; you need to spend some time studying it. I will provide a general description of how I used XmlSerializer and EncryptedXml together. Note that the following will encrypt and decrypt the entire document; if you want to do just specific fields (portions) of a XML document then you will need to do that differently from the following.
To deserialize the XML in, use XmlDocument.Load to load the XML. Then use that document to create a EncryptedXml object.
Instead of using FileStream to serialize the XML out, use TextWriter, then use TextWriter.ToString() to get the XML as a string. Then use XmlDocument.LoadXml to load the XML from the string. Then use XmlDocument.FirstChild.NextSibling to get the root node. Then cast the XmlNode to an XmlElement and then you can use that in EncryptedXml.EncryptData. There is probably a simpler more direct way to do that but that is what I have so far.
PriyamtheonePosted Feb 3, 2010, 9:20 AM
Sam HobbsPosted Feb 2, 2010, 2:26 PM
PriyamtheonePosted Feb 1, 2010, 2:56 AM
Mahesh ChandPosted Jan 31, 2010, 2:32 PM