Javascript Windows.System.Launcher.launchFileAsync(文件)不工作:(
我试着使用JSAPI开发Windows8应用商店应用程序。基本上我有两个按钮,一个调用函数create(),另一个调用函数open()。 文件创建正确,但我无法想象如何启动外部应用程序来打开它 鉴于此代码主要取自MSDN网站……我应该写什么来代替: //如何启动应用程序来读取文件 该文件存在,我可以通过var file=Windows.Storage.StorageFile.getFileFromApplicationUrisync(uri)获取其引用 但即使是Windows.System.Launcher.launchFileAsync(文件)也无法工作…:( 有什么帮助吗 谢谢Javascript Windows.System.Launcher.launchFileAsync(文件)不工作:(,javascript,api,sdk,windows-8,launcher,Javascript,Api,Sdk,Windows 8,Launcher,我试着使用JSAPI开发Windows8应用商店应用程序。基本上我有两个按钮,一个调用函数create(),另一个调用函数open()。 文件创建正确,但我无法想象如何启动外部应用程序来打开它 鉴于此代码主要取自MSDN网站……我应该写什么来代替: //如何启动应用程序来读取文件 该文件存在,我可以通过var file=Windows.Storage.StorageFile.getFileFromApplicationUrisync(uri)获取其引用 但即使是Windows.System.La
function create() {
{
localFolder.createFileAsync("dataFile.txt", Windows.Storage.CreationCollisionOption.replaceExisting)
.then(function (sampleFile) {
var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
var timestamp = formatter.format(new Date());
return Windows.Storage.FileIO.writeTextAsync(sampleFile, timestamp);
}).done(function () {
});
}
}
function open() {
localFolder.getFileAsync("dataFile.txt")
.then(function (sampleFile) {
if (sampleFile) { console.log("it does exists") }
return Windows.Storage.FileIO.readTextAsync(sampleFile);
}).done(function (timestamp) {
var uri = new Windows.Foundation.Uri('ms-appx:///dataFile.txt');
var file = Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri);
//how to launch an app to read the file?
}, function () {
console.log("timestamp non trovato");
});
}
这里有几件事:
var uri = new Windows.Foundation.Uri('ms-appdata:///local/dataFile.txt');
localFolder.getFileAsync("dataFile.txt")
.then(function (sampleFile) {
Windows.System.Launcher.launchFileAsync(sampleFile);
return Windows.Storage.FileIO.readTextAsync(sampleFile);
},
function () { console.log("it does not exist"); })
.done(function (timestamp) {
// not sure what you want to do here
}, function () {
console.log("timestamp non trovato");
}
);});
谢谢你,吉姆。我检查了你的答案是否正确。你太好了。谢谢你抽出时间!
localFolder.getFileAsync("dataFile.txt")
.then(function (sampleFile) {
Windows.System.Launcher.launchFileAsync(sampleFile);
return Windows.Storage.FileIO.readTextAsync(sampleFile);
},
function () { console.log("it does not exist"); })
.done(function (timestamp) {
// not sure what you want to do here
}, function () {
console.log("timestamp non trovato");
}
);});