0

I need help in formatting a string in C#.Simple one, but can't get the fog of my mind.

I have a foxit reader which reads the .pdf file and prints it on to the printer, the user chooses.

MergerPDF.destinationfile is the location of file

PrinterName = @"Companyhi-spdSupply";
commandLine.Arguments = " //t " + mergedPDF.destinationfile + " " + PrinterName;

We are trying to execute it from C# code, which triggers a generic syntax error. Here is the program call statement :

commandLine.Arguments?  " //t C:\\EDR Parser\\EDR\\2016-05-27_09-07_Zero.pdf Comapnyhi-spdSupply"   

We have the command line printing , which is working, when we give this command:

/t "C:\EDR Parser\EDR\2016-05-26_10-56_non_Zero.pdf" Companyhi-spdSupply
Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
SaraDob
  • 77
  • 11

3 Answers3

1

Without gettign too fancy, if commandline.Arguments will take it

commandLine.Arguments = @" /t """  + @mergedPDF.destinationfile.Replace("\\\\", "\\") + @""" " + PrinterName;

the output string is

/t "C:\EDR Parser\EDR\2016-05-27_09-07_Zero.pdf" Companyhi-spdSupply
langc334
  • 50
  • 7
0

This seems to produce the correct output for me:

var PrinterName = "Comapnyhi-spdSupply";
var DestFile = "C:\\EDR Parser\\EDR\\2016-05-27_09-07_Zero.pdf";
var Arguments = " /t \"" + DestFile + "\" " + PrinterName;
Console.WriteLine(Arguments);

Output:

/t "C:\EDR Parser\EDR\2016-05-27_09-07_Zero.pdf" Comapnyhi-spdSupply

It looks like you tried to escape the "/" when you don't need to, and you didn't add the embedded quotes around the filename with \"

Bradley Uffner
  • 16,641
  • 3
  • 39
  • 76
0

I could not comment yet, but give this a try:

remove the extra '/' in //t you don't need to escape the slash character.

commandLine.Arguments?  " /t C:\\EDR Parser\\EDR\\2016-05-27_09-07_Zero.pdf Comapnyhi-spdSupply"