How do I launch a pdf file in csharp?

  • Thread starter Thread starter Tim Osborne
  • Start date Start date
T

Tim Osborne

Hi

I am writing a simple winforms application that allows me to select a pdf
file on disk,
and have it launch Adobe Acrobat.

In the Win32 c++ world I would just do a ShellExecute.

How can I accomplish this in csharp?

Or do I have to write some managed c++ module to do this?
 
Tim,

You will want to call the static Start method on the Process class.

Hope this helps.
 
Hi Tim!

this is how I stop the SQL Server:

Process stopServer = new Process();

stopServer.StartInfo.FileName = "net";

stopServer.StartInfo.Arguments = "stop MSSQL$" + this.ServerInfo[2];

stopServer.StartInfo.CreateNoWindow = false;

stopServer.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

stopServer.Start();

stopServer.WaitForExit();

Explanation:

1. First you create a Process 2. You give a starting argument to the
process - that is the program you are starting. In your case that would be
acrobat.exe or something like that 3. Then you give arguments to the
program you are running. You have acrobat.exe as the program and you define
"test.pdf" as the argument 4. The next two lines just mean that you want a
hidden window. 5. Then you start the process and wait for it to exit before
you continue with your program (optional).

Hope this helps,

saso

Nicholas Paldino said:
Tim,

You will want to call the static Start method on the Process class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tim Osborne said:
Hi

I am writing a simple winforms application that allows me to select a pdf
file on disk,
and have it launch Adobe Acrobat.

In the Win32 c++ world I would just do a ShellExecute.

How can I accomplish this in csharp?

Or do I have to write some managed c++ module to do this?
 
Back
Top