This seems like such an obscure question, but here it goes:
Is there a way to concatenate String Literals with a DirectoryInfo enumeration (which contains a file path) while adding quotations around the file path? Further, how can I prevent backslashes from being doubled when converting a DirectoryInfo enumeration to a string? My situation is as follows:
DirectoryInfo filePathDirectory = new DirectoryInfo(filePath);
Process a = new Process();
a.StartInfo.FileName = "C:\\Windows\\system32\\lpr.exe";
a.StartInfo.Arguments = "-SServername.Domain.net -Plp " + "\"" + filePathDirectory + "\"";
a.StartInfo.UseShellExecute = false;
a.Start();
a.WaitForExit();
filePathDirectory
starts with a value of:
{\\ServerName\Share\Folder\Folder\FileName.xls}
Which I think is converted into a string once concatenated into a.StartInfo.Arguments
which is assigned the value of:
-SServername.Domain.net -Plp \"\\\\ServerName\\Share\\Folder\\Folder\\FileName.xls\"
This is bad because, the number of backslashes in the path doubled. How can I ensure no backslashes are added to the path?
On top of that, to add a quotation marks, I've used the backslash escape sequence; But the backslash from this escape sequence is inadvertently added to my string. How can I add quotation marks around the file path which is contained in a.StartInfo.Arguments
?
P.S. I hope this makes sense, please ask questions if you need clarification.