0

I have a printer hooked up to my pc and I'm creating a server so that anyone in my WLAN can access the printer. I'm using the following code to open a default print dialog:

Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
    CreateNoWindow = true,
    Verb = "print",
    FileName = @"C:\Users\User\Pictures\HurwitzofAz3p4j.png"
};
p.Start();

My question is how to acctualy start printing, i.e. trigger the print button click in the window opened (print dialog form)?

Amad
  • 25
  • 9
  • 1
    If you want to open a dialog, you do not want to press the button, because if you do want to press the button, then you [don't need the dialog](https://stackoverflow.com/a/5750704/11683). – GSerg May 21 '20 at 12:13
  • @GSerg I'd like to be able to print any type of file, i.e. not only images but also pdfs or text files – Amad May 21 '20 at 12:20
  • 2
    The `print` verb launches the application associated with the file, and tells it to print. It's up to the application what it does next. It may start printing straight away or display a dialog, and if it does, you will not know what kind of dialog it is because it's different in each application. So you will not be able to click the print button in a dialog displayed for any file type, or even be sure that such button exists, or that even the dialog itself exists. – GSerg May 21 '20 at 12:27
  • @GSerg yes, you're right. When starting the print process on pdf, no dialog pops up, which is cool. It would be nice if it happened to other types of file too. If there is no convienient way of doing this, I'll try to bear with it – Amad May 21 '20 at 12:38

0 Answers0