Search code examples
windows-phone-8compatibilitywindows-10-mobile

Will current Windows Phone 8.1 apps run on Windows 10 Mobile devices whitout any code modifications?


Currently I have wp8 applications running on windows 10 mobile devices, but I am getting some unexpected results, specially with photo related tasks.

This is what is not working well:

//Initializations for photo chooser task 
PhotoChooserTask photoChooserTask = new PhotoChooserTask(); 
photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
...

//Starting the photo chooser 
photoChooserTask.Show();
...

//Getting result from photo chooser 
void photoChooserTask_Completed(object sender, PhotoResult e)
{
   String photoPath = e.OriginalFileName;
}

This works well in an wp8 app installed on windows phone 8.1 device, getting always something like:

photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"

But has unexpected behavior in the same wp8 app installed on windows 10 device, sometimes getting something like:

photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"

But other times I get the following in the same device:

photoPath = "C:\Data\Users\DefApps\AppData\{82D0A9BD-6D54-4321-880B-445007A2A1B4}\local\PlatformData\PhotoChooser-b001485c-f41b-4676-b655-7aacee3d8267.jpg"
//This is not the real name of the saved photo, then is going to be a big problem if you want to save the name into a database an later use it to read the photo again.

I am testing this in the following devices: Nokia Lumia 520 (windows phone 8.1 operating system) Microsoft Lumia 550 (windows 10 mobile operating system)


Solution

  • I'd think this is by design. In Data for Windows Phone 8, we can find PlatformData is one of Special-use folders in the local folder:

    This folder is created when your app uses the photo chooser task. For more info, see How to use the photo chooser task for Windows Phone 8.

    And in How to use the photo chooser task for Windows Phone 8, it declared that

    If an app that targets Windows Phone OS 7.1 is deployed to a phone running Windows Phone 8 and that app uses the photo chooser task, the system will create a directory in the top level of the app’s isolated storage called "PlatformData".

    What happens in your scenario is similar, the system automatically creates "PlatformData" folder when your Windows Phone 8 app is deployed to Windows 10 Mobile.

    As this is controlled by system, I'm afraid there is no workaround for this. If your app is a Windows Phone Silverlight 8.1 app, I'd suggest using a file picker instead of photo chooser task. Or you can port your app to Windows 10 like Move from Windows Phone Silverlight to UWP.