Abdullah Arshad

Abdullah Arshad

  • NA
  • 5
  • 19.1k

Command Line Print embedded in C# not working

Jul 24 2012 9:52 AM
HI There

I'm using FOXIT READER to print a PDF to a network.

When I run the following in command line at DOS prompt

C:\Program Files (x86)\Foxit Software\Foxit Reader>"foxit reader.exe" /t "c:\po222.pdf" "\\CCS-BAR-001\NRG SP 4100N PS 

It works fine

 
However, when I embed the command line into Visual Studio C# using the Process Class, it fails to recognize the printer name.

 

I think this has something to do with there being both a double forward slash and single forward slash in the printer name which C# is failing to recognise even though I am using @ in front of the string to represent the literal string.

 

My C# code is :

 

            string testFile = "c:\\po222.pdf";

            string testPrinter = @"\\CCS-BAR-001\NRG SP 4100N PS";

 

            Process pdfProcess = new Process();

            pdfProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

            pdfProcess.StartInfo.FileName = @"C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe";

            pdfProcess.StartInfo.Arguments = string.Format("/t {0} {1}", testFile, testPrinter);

            pdfProcess.StartInfo.CreateNoWindow = false;

            pdfProcess.Start();

            pdfProcess.CloseMainWindow();

I can't see what I'm doing wrong. Can you spot anything out of place.

 

Any help would be gratefully received.
 

Kind regards

 

Abdullah


Answers (4)