当前 Windows Phone 8.1 应用程序 运行 在 Windows 10 移动设备上是否没有任何代码修改?
Will current Windows Phone 8.1 apps run on Windows 10 Mobile devices whitout any code modifications?
目前我在 windows 10 台移动设备上有 wp8 应用程序 运行,但我得到了一些意想不到的结果,特别是与照片相关的任务。
这是工作不正常的地方:
//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;
}
这在 windows phone 8.1 设备上安装的 wp8 应用程序中运行良好,总是得到类似的东西:
photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"
但在安装在 windows 10 台设备上的同一个 wp8 应用程序中出现意外行为,有时会出现类似以下内容:
photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"
但其他时候我在同一台设备上得到以下信息:
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.
我正在以下设备中对此进行测试:
诺基亚 Lumia 520(windows phone 8.1 操作系统)
微软 Lumia 550(windows 10 移动操作系统)
我认为这是设计使然。在Data for Windows Phone 8中,我们可以发现PlatformData是本地文件夹特殊用途文件夹之一:
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.
并且在 How to use the photo chooser task for Windows Phone 8 中声明
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".
您的情况类似,当您的 Windows Phone 8 应用程序部署到 Windows 10 Mobile 时,系统会自动创建 "PlatformData" 文件夹。
由于这是由系统控制的,恐怕没有解决方法。如果您的应用程序是 Windows Phone Silverlight 8.1 应用程序,我建议您使用 file picker instead of photo chooser task. Or you can port your app to Windows 10 like Move from Windows Phone Silverlight to UWP。
目前我在 windows 10 台移动设备上有 wp8 应用程序 运行,但我得到了一些意想不到的结果,特别是与照片相关的任务。
这是工作不正常的地方:
//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;
}
这在 windows phone 8.1 设备上安装的 wp8 应用程序中运行良好,总是得到类似的东西:
photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"
但在安装在 windows 10 台设备上的同一个 wp8 应用程序中出现意外行为,有时会出现类似以下内容:
photoPath = "C:\Data\Users\Public\Pictures\Camera Roll\WP_20170504_002.jpg"
但其他时候我在同一台设备上得到以下信息:
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.
我正在以下设备中对此进行测试: 诺基亚 Lumia 520(windows phone 8.1 操作系统) 微软 Lumia 550(windows 10 移动操作系统)
我认为这是设计使然。在Data for Windows Phone 8中,我们可以发现PlatformData是本地文件夹特殊用途文件夹之一:
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.
并且在 How to use the photo chooser task for Windows Phone 8 中声明
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".
您的情况类似,当您的 Windows Phone 8 应用程序部署到 Windows 10 Mobile 时,系统会自动创建 "PlatformData" 文件夹。
由于这是由系统控制的,恐怕没有解决方法。如果您的应用程序是 Windows Phone Silverlight 8.1 应用程序,我建议您使用 file picker instead of photo chooser task. Or you can port your app to Windows 10 like Move from Windows Phone Silverlight to UWP。