Winforms Telerik PDF查看器未加载

Winforms Telerik PDF查看器未加载,winforms,azure,telerik,blob,pdfviewer,Winforms,Azure,Telerik,Blob,Pdfviewer,我试图使用Telerik的RadPdfViewer,但遇到了一个问题。我似乎无法让它加载任何文档。我正在尝试从一个blob中通过流从azure存储加载,我已正确连接到该blob,但我似乎无法让pdf查看器显示pdf 如果有人能给我指出正确的方向,我将不胜感激 以下是我从blob获取pdf的代码: public byte[] PreviewBlob(string blobUri) { //Create the credentials to save to Azure

我试图使用Telerik的RadPdfViewer,但遇到了一个问题。我似乎无法让它加载任何文档。我正在尝试从一个blob中通过流从azure存储加载,我已正确连接到该blob,但我似乎无法让pdf查看器显示pdf

如果有人能给我指出正确的方向,我将不胜感激

以下是我从blob获取pdf的代码:

    public byte[] PreviewBlob(string blobUri)
    {
        //Create the credentials to save to Azure Blob
        StorageCredentials credentials = new StorageCredentials("pdmacstorage", "IhaveThisEnteredCorrectlyNoWorries");

        //Set the top level container for the file
        folderPath = "job-file";

        //Connect to Azure using the above credentials
        CloudBlobClient client = new CloudBlobClient(new Uri("https://pdmacstorage.blob.core.windows.net/"), credentials);

        //Get refrence to the container
        CloudBlobContainer container = client.GetContainerReference(folderPath);

        //Get refrence to the blob
        CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobUri);

        using(var memoryStream = new MemoryStream())
        {
            blockBlob.DownloadToStream(memoryStream);
            return memoryStream.ToArray();
        }
    }
下面是我从另一个表单调用它的代码:

    private Stream callPDFPreivew()
    {
        //Connection to PDData AzureJobFileUploader
        AzureJobFileUploader azureFileUpload = new AzureJobFileUploader();

        using(var memoryStreamFromByte = new MemoryStream(azureFileUpload.PreviewBlob(file.Name)))
        {
            return memoryStreamFromByte;
        }
    }
最后,这就是我调用方法的方式,我把它放在了一个选择更改中

    pdfViewer.LoadDocument(callPDFPreivew());

我没有一个AzureBlob实例来测试这一点,但是流可能需要重新定位

请尝试以下快速测试:


使用(var memoryStreamFromByte=newmemorystream(azureFileUpload.PreviewBlob(file.Name)))
{
memoryStreamFromByte.Position=0;
返回memoryStreamFromByte;
}


如果这不起作用,那么我可以在这里直接使用blob凭据测试这一点

谢谢你的建议,Lance,但是我能够找到一个使用此代码的方法

                            using(WebClient client = new WebClient())
                    {
                        using(Stream ms = new MemoryStream(client.DownloadData(file.Uri.ToString())))
                        {
                            MemoryStream mStream = new MemoryStream();
                            mStream.SetLength(ms.Length);
                            ms.Read(mStream.GetBuffer(), 0, (int) ms.Length);
                            pdfViewer.LoadDocument(mStream);
                        }
                    }

是我从哪里得到代码的

非常好。这与它从位置0读取流基本上是一样的。是的,但是我不得不添加额外的用法,我仍然不知道为什么其他方法不起作用,为什么它甚至没有给我一个错误。