Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:56:26+00:00 2026-06-12T01:56:26+00:00

This seems like such an obscure question, but here it goes: Is there a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:56:28+00:00Added an answer on June 12, 2026 at 1:56 am

    The backslashes are not doubled and the backslash of the quotes also “isn’t there”. You can verify it by Console.WriteLine(a.StartInfo.Arguments) or MessageBox.Show(a.StartInfo.Arguments).

    What you are seeing – in the debugger I assume – is the representation of the string with the escape characters not translated – just as you would need to enter it in the IDE.

    Example:

    string s = "\"";
    

    This will show in the debugger as "\"" but it will display on screen as ":

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like such a trivial question to ask, but it's been vexing me
This seems like such a simple question, but I have been trying for an
This seems like such a simple question, but I've given it the obligatory 30
This seems like such a ridiculous question, but our intranet portal which hosts hundreds
Sorry, this seems like such an obvious question, but I just can't find an
This seems like such a simple question, but I'm having such difficulty with it.
This seems like such a simple issue but I cannot find an elegant solution.
This seems like such a simple question. I have several Edit boxes on my
This seems like a repeated question but i'm not able to get my answer.
This seems like the simplest Git question, but I can't find ANYTHING on it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.