Can anyone help on the above. I'm not familar with MemoryStream Class however read the msn article at: http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx
But still not 100% sure on how to do the above. Webservice will be sending across a pdf file as binary data and I need to store it in memory and then allow the user the ability to download it, code I have done to date below:
puthsardarad...
Member
3 Points
29 Posts
Using MemoryStream Class to retrieve binary data for pdf and doc and allow download help
Jun 12, 2008 09:49 AM|LINK
Hi,
Can anyone help on the above. I'm not familar with MemoryStream Class however read the msn article at: http://msdn.microsoft.com/en-us/library/system.io.memorystream.aspx
But still not 100% sure on how to do the above. Webservice will be sending across a pdf file as binary data and I need to store it in memory and then allow the user the ability to download it, code I have done to date below:
aspx:
<asp:ImageButton runat="Server" ID="imgDoc" CommandName='imgDoc' CommandArgument='<%# Eval("systemId") %>' ImageUrl="~/img/word-icon.gif" width="60" OnCommand="imgDoc_Click" /> <asp:ImageButton runat="Server" ID="imgPDF" CommandName='imgPDF' CommandArgument='<%# Eval("systemId") %>' width="60" ImageUrl="~/img/pdf-icon.gif" OnCommand="imgPDF_Click" />
C#:
data.recordType = "PDF";
if (e.CommandArgument != null)
data.systemId = e.CommandArgument.ToString();
input2.standardInput = x;
input2.serviceInput = data;
try
{
output2 = abc.loadSysRecord(input2);
// lit2.Text += output2.serviceOutput.binaryData;
}
Download Files Webservice pdf Binary memorystream
Vince Xu - M...
All-Star
80367 Points
6801 Posts
Re: Using MemoryStream Class to retrieve binary data for pdf and doc and allow download help
Jun 16, 2008 08:13 AM|LINK
Hi,
The function for converting file to byte[].
private byte[] WriteFile(string filename)//convert file to byte[]
{
FileStream fs = File.OpenRead(filename);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
return buffer;
}
new MemoryStream((byte[])result) can be converted to MemoryStream.
Hope it helps.