Launching PDF reader on windows phone 8

后端 未结 3 1429
野性不改
野性不改 2021-01-25 11:54

I\'m trying to launch pdf reader with the code below but it does not work. Can somebody help me?

    private async Task WriteData(string fileN         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-25 12:33

    Called the API and saved the byte array to file

        public static async void WriteDataToIsolatedStorageFile(string fileName, byte[] data)
        {
            using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream stream = storageFile.OpenFile(fileName, FileMode.Create))
                {
                    if ((data != null) && (data.Length > 0))
                    {
                        await stream.WriteAsync(data, 0, data.Length);
                    }
                }
            }
        }
    

    opened the file in pdf reader using

        private async void StartExternalPDFApp()
        {
            StorageFolder localFolder = await FileManager.FindDirectory(FileManager.RelativeStorageDirectoryLocalStorage);
            StorageFile storageFile = await localFolder.GetFileAsync(PdfFileName);
            await Windows.System.Launcher.LaunchFileAsync(storageFile);
        }
    

    localFolder is Windows.Storage.ApplicationData.Current.LocalFolder

提交回复
热议问题