Our WPF desktop application downloads some images at startup from a server in the cloud. Since the download takes some time (up to a minute) and the images rarely change I would like to cache them to the user's disk so that they won't be loaded on subsequent startups.
Where would be the appropriate place to put them? The files may live for a long time (years), but if they are deleted, the startup will just download them again.
The options I've considered is to put them in the TEMP folder (which path I get from Path.GetTempPath()
) or in IsolatedStorage
. I don't know which would be best or if there is a better option.
I would go for ApplicationData if I wanted the pictures to be accessed only by the logged in user as it is:
You can access it like this:
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AppName", "Images");
And I would go for CommonApplicationData if I wanted the pictures to be accessed by all users at this machine as it is:
You can access it like this:
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "AppName", "Images");