Skip to content

Commit 15278fc

Browse files
Ron PetrushaBillWagner
andauthored
Differentiated Arguments and ArgumentList properties (#2611)
* Differentiated Arguments and ArgumentList properties * Apply suggestions from code review Co-Authored-By: Bill Wagner <[email protected]>
1 parent d6d3477 commit 15278fc

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

xml/System.Diagnostics/ProcessStartInfo.xml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,24 @@
237237
<summary>Gets a collection of command-line arguments to use when starting the application.</summary>
238238
<value>A collection of command-line arguments.</value>
239239
<remarks>
240-
<format type="text/markdown"><![CDATA[If you use this property to set command-line arguments, <xref:System.Diagnostics.ProcessStartInfo.Arguments> must be set to an empty string.
240+
<format type="text/markdown"><![CDATA[
241+
242+
`ArgumentList`, which is supported starting with .NET Core 2.1 and .NET Standard 2.1, and the <xref:System.Diagnostics.ProcessStartInfo.Arguments> property are independent of one another. That is, the strings assigned to the `ArgumentList` collection are not used to populate the <xref:System.Diagnostics.ProcessStartInfo.Arguments> property, and the string assigned to the <xref:System.Diagnostics.ProcessStartInfo.Arguments> property is not parsed into individual strings that are assigned to `ArgumentList` collection.
243+
244+
`ArgumentList` is easier to use than the <xref:System.Diagnostics.ProcessStartInfo.Arguments> property. Because each string is assigned to a member of the collection, you can single- rather than triple-escape strings that are delimited by quotation marks. For example, the following example include `-full "Mary Smith"` as a member of the `ArgumentList` collection:
245+
246+
```csharp
247+
info.ArgumentList.Add("-full \"Mary Smith\"";
248+
```
249+
250+
The corresponding assignment to the <xref:System.Diagnostics.ProcessStartInfo.Arguments> property is:
251+
252+
```csharp
253+
info.Arguments = "-full \"\"\"Mary Smith\"\"\""
254+
```
255+
256+
If you use this property to set command-line arguments, <xref:System.Diagnostics.ProcessStartInfo.Arguments> must be set to an empty string.
257+
241258
## Examples
242259
243260
This example adds two arguments to the process start info.
@@ -322,14 +339,20 @@ info.ArgumentList.Add("-last Smith")
322339
</ReturnValue>
323340
<Docs>
324341
<summary>Gets or sets the set of command-line arguments to use when starting the application.</summary>
325-
<value>A single string containing the arguments to pass to the target application specified in the <see cref="P:System.Diagnostics.ProcessStartInfo.FileName" /> property. The default is an empty string (""). On Windows Vista and earlier versions of the Windows operating system, the length of the arguments added to the length of the full path to the process must be less than 2080. On Windows 7 and later versions, the length must be less than 32699.
326-
327-
Arguments are parsed and interpreted by the target application, so must align with the expectations of that application. For.NET applications as demonstrated in the Examples below, spaces are interpreted as a separator between multiple arguments. A single argument that includes spaces must be surrounded by quotation marks, but those quotation marks are not carried through to the target application. In include quotation marks in the final parsed argument, triple-escape each mark.</value>
342+
<value>A single string containing the arguments to pass to the target application specified in the <see cref="P:System.Diagnostics.ProcessStartInfo.FileName" /> property. The default is an empty string ("").
343+
</value>
328344
<remarks>
329-
<format type="text/markdown"><![CDATA[If you use this property to set command-line arguments, <xref:System.Diagnostics.ProcessStartInfo.ArgumentList*> must not contain any elements.
345+
<format type="text/markdown"><![CDATA[
346+
347+
The length of the string assigned to the `Arguments` property must be less than 32,699.
348+
349+
Arguments are parsed and interpreted by the target application, so must align with the expectations of that application. For .NET applications as demonstrated in the Examples below, spaces are interpreted as a separator between multiple arguments. A single argument that includes spaces must be surrounded by quotation marks, but those quotation marks are not carried through to the target application. To include quotation marks in the final parsed argument, triple-escape each mark.
350+
If you use this property to set command-line arguments, <xref:System.Diagnostics.ProcessStartInfo.ArgumentList> must not contain any elements.
330351
352+
`Arguments` and <xref:System.Diagnostics.ProcessStartInfo.ArgumentList>, which is supported starting with .NET Core 2.1 and .NET Standard 2.1, are independent of one another. That is, the string assigned to the `Arguments` property does not populate the <xref:System.Diagnostics.ProcessStartInfo.ArgumentList> collection, and the members of the <xref:System.Diagnostics.ProcessStartInfo.ArgumentList> collection are not assigned to the `Arguments` property.
353+
331354
## Examples
332-
The first example below creates a small application (argsecho.exe) that echos its arguments to the console. The second example creates an application that invokes argsecho.exe to demonstrate different variations for the Arguments property.
355+
The first example creates a small application (argsecho.exe) that echos its arguments to the console. The second example creates an application that invokes argsecho.exe to demonstrate different variations for the `Arguments` property.
333356
334357
[!code-cpp[Process.Start_static#3](~/samples/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp#3)]
335358
[!code-csharp[Process.Start_static#3](~/samples/snippets/csharp/VS_Snippets_CLR/Process.Start_static/CS/processstartstatic.cs#3)]
@@ -1824,4 +1847,4 @@ When <xref:System.Diagnostics.ProcessStartInfo.UseShellExecute> is `false`, the
18241847
</Docs>
18251848
</Member>
18261849
</Members>
1827-
</Type>
1850+
</Type>

0 commit comments

Comments
 (0)