.Net has excellent feature called Isolated Storage. Isolated storage means saving the data in an isolated place. CLR provides standard place to store this data, but it does not impose any format for the isolated data. Which means you can store any data whether the data is in text format or in XML format, CLR does not stop you to use Isolated Storage feature.
We can use the Isolated Storage facility through System.IO.IsolatedStorage namespace. In this article we discuss about Isolated Storage feature with simple example.
Open Microsoft Visual Studio 2013 => Create Console Application and name it as CSharpIsolatedStorage.
Write the code as shown below by using System.IO & System.IO.IsolatedStorage namespaces.
using System;
using System.IO;
using System.IO.IsolatedStorage;
namespace CSharpIsolatedStorage
{
class Program
{
static void Main(string[] args)
{
IsolatedStorageFileStream objIsolated = new IsolatedStorageFileStream("CSharpIsolated.abc", FileMode.Create);
StreamWriter writer =
new StreamWriter(objIsolated);
String output;
System.DateTime currentTime = System.DateTime.Now;
output = "This is simple text data testing the .Net Isolated Storage feature";
writer.WriteLine(output);
writer.Flush();
writer.Close();
objIsolated.Close();
}
}
}
As shown above we are storing the text data in CSharpIsolated.abc file through the Isolated Storage feature. As you seen we are using our own extension .abc, because Isolated Storage feature allows us to store data in any format.
Run the application and search for the CSharpIsolated.abc file in your hard disk, you can find that file with the given data. In my system it stored in c:\Documents and Settings\Administrator\ApplicationData\Microsoft\COMPlus\IsolatedStorage\0.2\Url.affyycdfe3grdss\files location.