locked
Advise on donwloading files locally

    General discussion

  • Dear all,

    I am actuially building a mobile store app in c# and WPF which is collected data from REST web service and store them locally into SQlite in case of later not available network. This way our app can work in online and off line.

    During the time we donwload data , some items are linked to a photo or document through an URL.

    For exemple if I download a product data which is a Car, I would like to donwload as well associated picture with that Car.
    In local database, I have reference of all pictures attached to an items though a dedicated tablle where I have store the URL to reach the file.

    The question I have is based on the way to sycnhronise those picture files :

    - Is it better to request them at the needed time ? but then if not network connection I will have no picture displayed

    - Is it better to donwload them all at least once locally ?

    If option 2, where is the best place to store the pictures?

    regards

    Thursday, April 23, 2015 2:28 PM

All replies

  • >>Is it better to request them at the needed time ? but then if not network connection I will have no picture displayed

    It depends on how important it is for you and your application to actually be able to display these images. If it is important you should probably download the images while you can and store them either in the database or on the file system.

    >>Is it better to donwload them all at least once locally ?

    Yes, if you want to make sure that the images will always be available at the time when you actually need to display them you want to download them when as soon as you have access to the network. If you wait, there is a risk that the network will no longer be available by the time you decide to download/display them.

    >>If option 2, where is the best place to store the pictures?

    You could store them in your local SQLite database: http://www.codeproject.com/Articles/196618/C-SQLite-Storing-Images

    Or you could store the image files on the disk provided that you have write access to some folder.

    It is probably easier and it requires less code to save and retrieve the files directly to and from the disk but there is no right or wrong. If you are developing a Store App you could save the images to the local folder: https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localfolder?f=255&MSPPError=-2147217396. In WPF you could for example save the files in the directory of the executable (.exe) itself.

    Hope that helps.

    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Thursday, April 23, 2015 3:16 PM
  • Thnaks for your reply.

    Based on network connectivity, how to handle properly the fact that for instance I could start a sync donwload process of files or data, and then suddendly the device goes either in sleep mode or user press on shutdown by mistake .

    How to handle the fact that newtork can be available and suddenly is not anymore while donwload was processing.

    is tehre a clean way to restart from the point we were when network comes back ? or is is better to redo all ?

    regards

    Thursday, April 23, 2015 4:57 PM