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 6573567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:09:01+00:00 2026-05-25T15:09:01+00:00

I found the following snippet of the code: using System; using System.Diagnostics; public class

  • 0

I found the following snippet of the code:

using System;
using System.Diagnostics;

public class RedirectingProcessOutput
{
    public static void Main()
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.Arguments = "/c dir *.cs";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();

        string output = p.StandardOutput.ReadToEnd();
        p.WaitForExit();

        Console.WriteLine("Output:");
        Console.WriteLine(output);    
    }
}

but I can’t figure out what this p.StartInfo.Arguments = "/c dir *.cs"; is doing? thanks in advance for any explanation

  • 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-25T15:09:01+00:00Added an answer on May 25, 2026 at 3:09 pm

    In the beginning was exec(3) and its friends, which accept the path to an executable and a variable length list of pointers to arguments. In sane operating systems, The process that gets started receives a point to the argument list, each word of which contains a pointer to and individual string. Sane shells parse the command line and populate the argument list required by exec(3).

    You can see a direct correlation between the argument list accepted by exec(3):

    exec ("some.executable.file", "arg1" , "arg2" , "arg3" , ... ) ;
    

    and what gets passed to the entrypoint of the process:

    int main ( char *arg[] ) { … }

    where argv[0] is the executable name, and argv[1]—argv[n-2] are the individual arguments, and argv[n-1] is a NULL pointer to indicate the end of the argument list.

    Both conceptually simple and simple to implement.

    CP/M didn’t do it that way (I assume because of limited memory). It passed the started process the address of the raw command line from the shell and left its parsing up the process.

    DOS followed in 1982 as clone of CP/M, handing a started process the address of the raw command line as well.

    Windows hasn’t deviated from that model since its inception. The Win32 CreateProcess() function

    BOOL WINAPI CreateProcess(
      __in_opt     LPCTSTR lpApplicationName,
      __inout_opt  LPTSTR lpCommandLine,
      ...
    );
    

    still does the same thing, passing the raw command line to be passed to the program. The C runtime library, of course, takes care of the command line parsing for you…more or less.

    So…in the CLR/.Net world, because of all this history, and because the CLR was designed to be dependent on the Win32 APIs, you have pass a complete command line to the process to be started. Why they didn’t let you pass a params string[], instead and have the CLR build the command line is something that Microsoft’s developers kept close to their chest.

    Building the command line required by the started program is simple. You just join each argument into a single string with an SP character separating the arguments. Easy!

    …until one of your arguments contains whitespace or a double quote character (").

    Then you have to quote one or all of the arguments. Should be easy, but due to the bizarre quote rules, there are a lot of edge conditions that can trip you up.

    A Windows command-line is broken up into words separated by whitespace, optionally quoted with double-quoted ("). Partly because Windows also got the path separater wrong (\ rather than /), the quoting rules are…byzantine. If you dig into the Windows CRT source code (the file is something like {VisualStudioInstallLocation}\VC\crt\src\stdargv.c), you’ll find the command line parsing code.

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

Sidebar

Related Questions

I'm using the following code snippet to determine what process ID my vbscript is
On the MSDN, I have found following: public event EventHandler<MyEventArgs> SampleEvent; public void DemoEvent(string
I'm using the following snippet of code in an MVC Action to return an
What does isset($_SESSION) mean? I found the following code snippet- if (!isset($_SESSION)) { //
I was going through a legacy code and found the following snippet: MyClass::~MyClass() {
I'm pulling data from Dynamics AX 2009 from c# using the following code snippet.
I found a script which has the following snippet:- userid=`expr \`id\` : .*uid=[0-9]*(\(.[0-9a-z]*\)) .*`
I found the following code to create a tinyurl.com url: http://tinyurl.com/api-create.php?url=http://myurl.com This will automatically
I found the following code somewhere, but I am not understanding the code properly.
I was using the following code to retrieve HTML snippets from a database table

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.