× ABOUT DOWNLOADS PROJECTS WORK
    cyberpunk.sh
Profile photo

PREMCHAND CHAKKUNGAL

SENIOR SOFTWARE ENGINEER

    ASYNCHRONOUSLY LOAD BITMAP IMAGE FROM ISOLATEDSTORAGE

Given below is an asynchronous task to load an user image from the Isolated Phone Storage and return it as a BitmapImage object.


public async Task loaduserimage()
        {
            BitmapImage bi = new BitmapImage();

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {

                if (myIsolatedStorage.FileExists("filename.extension"))
                {
                     using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("filename.extension", FileMode.Open, FileAccess.Read))
                        {
                            bi.SetSource(fileStream);

                        }
                }
                else
                {
                    MessageBox.Show("File not found");

                }

            }
            return bi;
}