mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Added support for WP8
This commit is contained in:
parent
2686c86ac3
commit
3e48517abd
@ -37,4 +37,13 @@
|
||||
<header-file src="src/ios/FileOpener2.h" />
|
||||
</platform>
|
||||
|
||||
<!-- WP8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="FileOpener2">
|
||||
<param name="wp-package" value="FileOpener2" />
|
||||
</feature>
|
||||
</config-file>
|
||||
<source-file src="src/wp8/FileOpener2.cs" />
|
||||
</platform>
|
||||
</plugin>
|
||||
|
46
src/wp8/FileOpener2.cs
Normal file
46
src/wp8/FileOpener2.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media;
|
||||
using Windows.Storage;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
public class FileOpener2 : BaseCommand
|
||||
{
|
||||
|
||||
public async void open(string options)
|
||||
{
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
var fileName = System.IO.Path.GetFileName(args[0]);
|
||||
string aliasCurrentCommandCallbackId = args[2];
|
||||
|
||||
try
|
||||
{
|
||||
// Access isolated storage.
|
||||
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
|
||||
|
||||
// Access the file.
|
||||
StorageFile file = await local.GetFileAsync(fileName);
|
||||
|
||||
// Launch the bug query file.
|
||||
await Windows.System.Launcher.LaunchFileAsync(file);
|
||||
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.OK), aliasCurrentCommandCallbackId);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), aliasCurrentCommandCallbackId);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR), aliasCurrentCommandCallbackId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user