Thursday, 11 May 2017

NodeRT - StorageFile.openAsync returns undefined fileStream, but no error

I'm just getting started with NodeRT & Electron (Windows 10). Some of the basics seem to be working, but I've quickly run up against a strange issue. Here's the code:

const {FileAccessMode, StorageFile} = require('electron').remote.require('@nodert-win10/windows.storage')

var fname = require('electron').remote.app.getPath('userData') + '\\test.jpg';

StorageFile.getFileFromPathAsync(fname, (err, storageFile) => {
    if (err) return console.log(err);

    storageFile.openAsync(FileAccessMode.read, (err, fileStream) => {
        if (err) return console.log(err);

        // fileStream is NULL HERE!
    })
})

getFileFromPathAsync succeeds and the resulting storageFile is valid. However, openAsync returns an undefined fileStream and an undefined err!

Questions:

  • What am I doing wrong here?

  • In any case, why is openAsync failing silently with no error?

Thanks!



via logidelic

No comments:

Post a Comment