Problem with special char in path when passing DDE message to Acrobat Reader
I've been looking into a problem for some time without finding a solution to it. Tried google as well, without getting on track...
Any help would be appreciated!
Problem is:
I'm sending a DDE-command, to open a PDF document to print it silently. Problem is with the path, if it has non-ASCII chars. It would not get recognized and it throws an error. What should I do with the path string to avoid this and to get Acrobat reader to understand the path? I've tried with an "o" instead of "ø", and that works flaw开发者_Python百科lessly... Thanks in advance!
string file = @"C:\Users\Bø\1_tmp_printpages.pdf";
client.Execute("[DocOpen(\"" + file + "\")]", 60000);
client.Execute("[FilePrintSilent(\"" + file + "\")]", 60000);
client.Execute("[DocClose(\"" + file + "\")]", 60000);
client.Execute("[AppExit]", 60000);
I'm using NDde to pass DDE messages.
Since I couldnt find a DDE library other than NDde for C#, I was not able to process non US-ASCII symbols in my path. Therefore I decided to use a different approach, verbs.
Here is my new code that accepts non US-ASCII symbols. It's inside a try-block, and I'm doing some logic to kill AcroRd32 afterwards. But the code itself to print PDF silently is underneath... :)
System.Diagnostics.Process P = new Process();
P.StartInfo.FileName = mc.PrintPages;
P.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
P.StartInfo.Verb = "print";
P.StartInfo.Arguments = printDialog1.PrinterSettings.PrinterName.ToString();
P.StartInfo.CreateNoWindow = true;
P.Start();
精彩评论