locked
DataReader: opening file fails with "No such interface supported" error

    Question

  • Hello guys.

    I'm trying to create and open a file inside the temporary folder. Here's my current code for opening the file:

     

    function readFile() {
        var tempFolder = Windows.Storage.ApplicationData.current.temporaryFolder;
        tempFolder.createFolderAsync("testFolder", Windows.Storage.CreationCollisionOption.openIfExists)
            .then(function (folder) {
            return folder.createFileAsync("testFile.txt", Windows.Storage.CreationCollisionOption.openIfExists);
        })
            .then( function(file){
                return file.openAsync(Windows.Storage.FileAccessMode.read)
            })
            .then(function (stream) {
                var size = stream.size;
                if (size != 0) {
                    var inputStream = stream.getInputStreamAt(0);
                    var reader = new Windows.Storage.Streams.DataReader(stream);
                    reader.loadAsync(size)
                        .then(function () {
                            var contents = reader.readString(size);
                        });
                }
            });
    }

    Whenever I try to run it, I'll end up getting an exception on the DataReader object instantiation line. the error says "No such interface supported interface". Any clues?

    thanks.


    Luis Abreu
    Thursday, January 19, 2012 2:28 PM

Answers

All replies