File . one of one note does not open in windows phone 8.1 C#

Asked

Viewed 33 times

1

I have an app Windows Phone 8.1 that accesses Onedrive after authentication, I have access to all files/folders and subfolders of the logged in account. I’m having an error trying to open the one note native app after calling mine Task OpenFile.

Follows error:

Can’t open file There is a problem with this file and Onenote can’t open it

All files of the type: .docx/ .xlsx/ .pptx are opening native apps as expected.

Someone’s been through the same trouble?

public async Task OpenFile (IItem fileItem)
    {
        StorageFolder localFolder = ApplicationData.Current.LocalFolder;

        StorageFile storageFile = await localFolder.CreateFileAsync(fileItem.Name, CreationCollisionOption.ReplaceExisting);
        IRandomAccessStream writeStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite);

        using (Stream outputStream = Task.Run(() => writeStream.AsStreamForWrite()).Result)
        {                
            Stream downloadStream = await DownloadFileAsync(fileItem);

            await downloadStream.CopyToAsync(outputStream);
        }

        var filerun = await ApplicationData.Current.LocalFolder.GetFileAsync(fileItem.Name);

        var options = new LauncherOptions() { DisplayApplicationPicker = true };
        await Launcher.LaunchFileAsync(filerun, options);
    }

    public async Task<Stream> DownloadFileAsync(IItem file)
    {
        Stream stream = null;
        File fileDownload;

        fileDownload = file as File;

        stream = await fileDownload.DownloadAsync();

        return stream;
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.