I have a service which provides a stream. This stream should be written to a pdf-file.
I tried this method but it didn't work:
Using hcwHandler As IHealthCareWorkerServiceHandler = Container.CurrentContainer.Resolve(Of IHealthCareWorkerServiceHandler)()
stream = hcwHandler.DownloadPrescription(New DownloadPrescriptionRequest With {
.ProfessionCode = ucSelectProfession.ProfessionCode,
.RizivNumber = ucSelectProfession.Nihdi,
.Culture = language
}).Result
End Using
Dim buffer As Byte() = Encoding.ASCII.GetBytes(stream.ToString())
Using ms As New MemoryStream(buffer)
'write to file
Using file As New FileStream("prescription.pdf", FileMode.Create, FileAccess.Write)
ms.WriteTo(file)
End Using
End Using
I have tried several other solutions as well, but none seemed to work. I never get a file.
Can anyone help me?