I know how to store and retrieve data using isolated storage. My problem is how to sort the data I want to recover from that has already been stored previously. All my data is stored in a single file.

The user stores the data everyday and maybe on a particular date he makes two entries and none on some other day. In that case how should I search for the particular days info I need.

And could you also explain how data is stored in the isolated storage that is in packets of data or some other way? If I store two data sets in same file, does it automatically shift to a next line for storing other data or do I have to specify for it to do so?

Moreover, if I want to save data in the same line, does it automatically separate the data in a line by some tab or inserting some character in between two data sets in a line or does the developer have to take care of this?

有帮助吗?

解决方案

If the date is saved in the title of the file then you can use the following code to search for it:

var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
string date = appStorage.GetFileNames("the date you are looking for")

In answer to your other question if you use .Write() when writing text to a file, then it will create one long stream of data, if you use .WriteLine() then you will write the information, then a new line reference will be added at the end.

I'm not sure as you weren't very clear, but just in-case, here is a general procedure for reading files from IsolatedStorage:

var appStorage = IsolatedStorageFile.GetUserStoreForApplication();

using (StreamReader reader = new StreamReader(appStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read)))
    {
        fileContent = reader.ReadToEnd();    
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top