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

  • Home
  • SEARCH
  • 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 217421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:39:21+00:00 2026-05-11T18:39:21+00:00

How is it possible to parse command-line arguments that are to be interpreted as

  • 0

How is it possible to parse command-line arguments that are to be interpreted as paths? args[] contains strings that are automatically joined if they are quoted, e.g.:

example.exe one two “three four”

args[0] = one
args[1] = two
args[2] = three four

However, args[] will not property parse “C:\Example\” as an argument. Rather, it will supply the argument as “C:\Example”” (with the extra quote included.) This is due to the backslash in the path being treated as an escape character and thus the end quotation that the user supplied on the command-line becomes part of the argument.

.e.g:

example.exe one “C:\InputFolder” “C:\OutuptFolder\”

args[0] = one
args[1] = C:\InputFolder"
args[2] = C:\OutputFolder"

An easy kludge might be:

_path = args[i].Replace("\"", @"\");

However, I’m sure there is a best-practice for this. How might one correctly parse a command line that inlcudes paths, preventing the args[] array from improperly being populated with stings that have been parsed for escape characters?

NOTE: I would not like to include an entire command-line parsing library in my project! I need only to handle quoted paths and wish to do so in a “manual” fashion. Please do not reccomend NConsoler, Mono, or any other large “kitchen sink” command-line parsing library.

ALSO NOTE: As far as I can tell, this is not a duplicate question. While other questions focus on generic command-line parsing, this question is specific to the problem that paths introduce when parts of them are interpreted as escape sequences.

  • 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-05-11T18:39:21+00:00Added an answer on May 11, 2026 at 6:39 pm

    Not an answer, but here’s some background and explanation from Jeffrey Tan, Microsoft Online Community Support (12/7/2006):

    Note: this is not not a code defeat
    but by design, since backslashe are
    normally used to escape certain
    special character. Also, this
    algorithm is the same as Win32 command
    line arguments parsing function
    CommandLineToArgvW. See the Remarks
    section below:
    http://msdn2.microsoft.com/en-us/library/bb776391.aspx

    Also makes reference to the FX method Environment.GetCommandLineArgs for further explanation of the slash handling behavior.

    Personally I think this is a drag, and I’m surprised I haven’t been bit by it before. Or maybe I have and don’t know it? Blind replacement of quotes with slashes doesn’t strike me as a solution, though. I’m voting the question up, because it was an eye opener.

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

Sidebar

Ask A Question

Stats

  • Questions 115k
  • Answers 115k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $site = preg_replace('{/$}', '', $site); This uses a relatively simple… May 11, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer Finally I found the cause of the issue. It's a… May 11, 2026 at 10:20 pm
  • Editorial Team
    Editorial Team added an answer "Project" is not really a useful concept in Django. The… May 11, 2026 at 10:20 pm

Related Questions

I have written a standalone Java application that I've packaged into a jar file
I want to use php in console mode and create an environment to test
I'd like to parse status.dat file for nagios3 and output as xml with a
Optimization of PHP code via runtime benchmarking is straight forward. Keep track of $start
It's possible to write Markdown content with invalid syntax. Invalid means that the BlueCloth

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.