I'm currently working on a Windows 8.1 App for tablets. I want to call an xls file from the users drive on click. The problem is that the code I have so far does not prevent the App from crashing in case the file cannot be found. I need some kind of error handling that simply prevents that from happening and sends an alert or something.
Here is what I have so far
var me = this;
var fileName = "ReportCall.xls";
var localFolder = Windows.Storage.ApplicationData.current.localFolder;
var reportFile = localFolder.getFileAsync("Attachments\\Reports\\fileName");
var file = local.Folder.getFileAsync(fileName);
reportFile.done(function(file) {
Windows.System.Launcher.launchFileAsync(file).done(
function (success) {
if (success) {
// DO NOTHING
} else {
//Alert. File not found!
}
});
});
Any ideas?
Cheers
Managed to solve the problem with the following code
var me = this;
var fileName = "ReportCall.xls";
var localFolder = Windows.Storage.ApplicationData.current.localFolder;
var file = localFolder.getFileAsync(fileName):
localFolder.getFileAsync("Attachments\\Reports + fileName").then(function)(file {
},function(e) {
alert("file cannot be found");
});