Winform open WebService dime pdf attachment

S

Steve

I have a C#.net windows form project that connects to a webservice that
returns a dime attachment (pdf document). I need the winform to open and
load the pdf document into acrobat reader. I do not want to write the file
to the hard drive to create a path so that I can call
System.Diagnostics.Process.Start("AcroRd32.exe", strFileName); if I do not
have too.

I have a web project with an aspx page that opens the file without writing
to a filepath. I am looking for a similar solution in my winform.
Here is my web project aspx code:

System.IO.Stream objAtt = objResponseContext.Attachments[0].Stream;
byteContent = new Byte[objAtt.Length];
int len = objAtt.Read(byteContent, 0, (int)objAtt.Length);

Response.ContentType = "Application/pdf";
Response.BinaryWrite(byteContent);
Response.End();

The above code opens acrobat reader and loads the document.

I need some help finding a similar solutiion to the Response.ContnetType and
Response.BinaryWrite in windows forms. I would like to open the byteContent
directly into Acrobat reader. I am not sure how to do this.
 
L

Linda Liu [MSFT]

Hi Steve,

Firstly, I would say that in the sample web project you mentioned, when we
browse the aspx page that opens a pdf file, the pdf file is downloaded and
saved to the IE temporary folder on the client machine.

In Windows applications, we could lauch an exe file only using
System.Diagnostics.Process.Start method. It is not supported to pass an
argument of type byte array to this method.

What's more, since Acrobat Reader is a 3rd party product, Microsoft doesn't
provide some other ways to launch Acrobat Reader and open a pdf file in it
with a byte array.

In short, you should write the pdf file to the hard drive and then open it
in Acrobat Reader.

If you have any concerns, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steve

Linda,

Thank you for the update.

This confirms what we are currently doing in our windows forms projects. I
just wanted to make sure that we did not miss something that was in the .net
architecture.

Thank you,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top