Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net Open a pdf file in resources

Posted on 2014-11-20
3
Medium Priority
?
769 Views
Last Modified: 2014-11-23
Hi
I imported a pdf doc called test.pdf into my project resources and tried to open it using the following code
but I got the error shown in the image

Imports System.IO  
Imports System.Diagnostics  

        Dim pdf As Byte() = My.Resources.test

        Using tmp As New FileStream("test.pdf", FileMode.Create)

            tmp.Write(pdf, 0, pdf.Length)
        End Using

        Process.Start("test.pdf")

1
0
Comment
Question by:Murray Brown
3 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 40454740
Hi,

Maybe instead of FileMode.Create

FileMode.OpenOrCreate

or

FileMode.Open

Regards
0
 
LVL 11

Assisted Solution

by:LordWabbit
LordWabbit earned 1000 total points
ID: 40455032
The line Process.Start("test.pdf") has opened the document in Acrobat, find all instances of Acrobat that are currently running and stop them.
0
 

Author Closing Comment

by:Murray Brown
ID: 40461500
thanks for the help
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question