Download and save images into local phone storage makes the app hang

Hi I wrote a game and the app can download images from server and then store them inside Application.persistentDataPath.

My problem is when saving few images the scene is hang and when it is done saving, it executes the rest of the codes.

How to solve this issue?

Saving image into device local storage:

    if (File.Exists (Application.persistentDataPath + "/LayoutImages/")) {
        Debug.Log (imagesPathPrefix + " already exists.");
        return;
    }

    File.WriteAllBytes (Application.persistentDataPath + "/LayoutImages/abc.jpg", image);

How to solve this issue?

I “solved” it. The app will hang when run on computer when it downloads and saves the images in Application.persistentDataPath.
If I build and run the app in my phone, it will not hang when doing the same job under the same scripts.

Feel awkward and unpleasant even though it’s not an issue anymore…