Forum Xamarin.iOS

Help, Sandbox is deleting downloaded images Xamarin IOS

leonardoartuso2leonardoartuso2 Member ✭✭
edited May 2018 in Xamarin.iOS

Hi,

I have a problem that I have not seen any resolution so far, I have an application that downloads images to use, I saved it directly in the Environment.SpecialFolder.Personal, however, when the application updates, the sandBox it erases all caches, which to do in this situation?

how do I not allow deletion of these images or how do I save it to another directory that the sandbox does not delete?

Thanks

Best Answers

  • DannyCDannyC US ✭✭✭✭
    Accepted Answer

    Try the MyDocuments folder and see if that works for you. I know when running simulator path can change so try it on a physical device.

    var path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "DownloadedImages");
    var myDownloadedImage = Path.Combine(path, "Image.png");
    
  • DannyCDannyC US ✭✭✭✭
    Accepted Answer

    Glad it helped you find the issue. :smile:

Answers

  • DannyCDannyC US ✭✭✭✭

    That shouldn't occur, iOS won't delete any files other than the temporary folder. Double-check your code to make sure something isn't off. Also check the thread below. Also is this occurring when testing on Simulator or actual device?

    https://forums.xamarin.com/discussion/93775/files-doesnt-persist-after-next-deployment

  • leonardoartuso2leonardoartuso2 Member ✭✭

    @DannyC thanks for replying, however, it is deleting, this occurs when building or updating the application including it changes the address ID of the sandbox, you know where I can save the files in a secure folder that it does not delete, I think I am saving justly in the folder it deletes, would you know to tell me where I can save the files and how do I get the directory via code?

  • DannyCDannyC US ✭✭✭✭
    Accepted Answer

    Try the MyDocuments folder and see if that works for you. I know when running simulator path can change so try it on a physical device.

    var path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "DownloadedImages");
    var myDownloadedImage = Path.Combine(path, "Image.png");
    
  • leonardoartuso2leonardoartuso2 Member ✭✭

    thanks a lot for your help @DannyC, thanks to you I realized that what changes is the sandbox path, I saved in the bank the path of the file and to show the images I pull the bank path, thanks to you I realized that it does not deletes the file simply changes the path in which it is saved.

    Thank you even helped me a lot.

  • DannyCDannyC US ✭✭✭✭
    Accepted Answer

    Glad it helped you find the issue. :smile:

Sign In or Register to comment.