Can I find out when the IsolStorageFile was created without loading it?

we cache these objects in xml files and we will not ignore the cached file when 24+ has passed. I donโ€™t want to download the file to check if 24 hours have passed, so I wonder if there is a way to get the metadata of the file without downloading it. Sort of:

using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) { DateTime dateTimeCreated = file.GetAttributes(this.CacheFileName)["DateTimeCreated"]; } 

Tell me. Thanks!

+4
source share
4 answers

How about a log file? (or you could make a list of Date + Name in your application settings)

+1
source

There is no phone icon next to this method, so it is probably not available according to the documentation:

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefile(VS.95).aspx

Uggh ... maybe save a smaller file with only the latest recording time, so do you know if you need to upload a large one or ignore it? Or even some bizarre datetime in the file name itself?

+1
source

I would use isolStorageSettings.ApplicationSettings to save the file name and metadata associated with this file name as an instance of the class. I used this in my WP7 applications and it works great. A good scenario for this is to check the expiration of a file for some caching implementation, and if it has expired, I can delete the file directly.

0
source

I was thinking about what you can do, it's simple and close to your needs ...

If you are fine with current days, and not in the last 24 hours, then you can implement directories with the name date, for example, in the format yyyymmdd, and then in your interface layer iso find the file in the current day directory .. If you do not find it , then there is no cache and you create it.

At a time convenient for you, you could store at home to clean the catalogs of the current day.

This strategy will make your 24-hour framework look more like 0-24 hours .. so an average of 12 ... are skewed depending on the time of day when you think your users are most likely to use your application.

You can set the timeframe by using the algorithm to generate a directory. For example, you can force it to create a unique directory name every 2 days (on average for 24-hour caching).

If IsolatedStorageFile.GetFileNames () works with the file index, you can encode the date in the last part of the file name. Unfortunately, it still returns *. * Whatever.

0
source

All Articles