Is this possible with "Process"?

J

johnb41

I am using a "Process" to open a .pdf file in Acrobat Reader, like
this:

Dim proc As New Process
With proc.StartInfo
.FileName = "c:\filename.pdf"
.UseShellExecute = True
End With
proc.Start()

When the PDF file is open for viewing, I will eventually need Acrobat
to CLOSE the file, so i can programatically "move" the .pdf file to a
different location on my drive. But I can't because the file is in
use. Currently I have to manually close the .pdf file before moving
it.

Is there a way to have .net automatically close the file in Acrobat?

Thanks for all your help!

John
 
Z

Zoury

Hi John ! :O)
Is there a way to have .net automatically close the file in Acrobat?

using proc.CloseMainWindow() should close Acrobat (or any designated PDF
viewer) which should release the file ...

The question is, do you need the application to stay open ?
 
J

johnb41

Yanick,

Yes, ideally, I would like the app to stay open. So when the user
opens the next PDF file the entire Acrobat doesn't have to reload.

Is that possible? If not, for now I could deal with having the app
close. Not ideal, but maybe better than having to close the file
manually every time...

Thanks!
John
 
M

Mythran

johnb41 said:
Yanick,

Yes, ideally, I would like the app to stay open. So when the user
opens the next PDF file the entire Acrobat doesn't have to reload.

Is that possible? If not, for now I could deal with having the app
close. Not ideal, but maybe better than having to close the file
manually every time...

Thanks!
John

Before creating the process, copy the file to the user's temporary folder
and open the temporary copy instead. That way, you can move the file around
and access it all you want :)

Mythran
 

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