从字节数组ios xamarin c#打开pdf

时间:2016-10-31 00:18:29

标签: c# xamarin

我有一个包含pdf文档的字节数组,我想在ios应用程序中打开它。

到目前为止,这是我的代码:

public static string WriteFileFromByteArray(string fileName, byte[] bytes)
    {
        var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        var filePath = Path.Combine(documentsPath, fileName);
        File.WriteAllBytes(fileName, bytes);

        return filePath;
    }

有人知道怎么做吗?

1 个答案:

答案 0 :(得分:0)

不确定你到底在哪里。 但是您发布的以下代码行中存在一个问题。

File.WriteAllBytes(**fileName**, bytes);//在此代码中您使用的是文件名而不是文件路径。

使用filePath变量代替fileName,因为它只包含文件名。

请参阅以下链接以了解PDF查看器。

http://forums.xamarin.com/discussion/631/open-a-pdf-with-the-built-in-pdf-viewer

相关问题