System.Diagnostics.ProcessStartInfo.WorkingDirectory Property

When the ProcessStartInfo.UseShellExecute property is false, gets or sets the working directory for the process to be started. When ProcessStartInfo.UseShellExecute is true, gets or sets the directory that contains the process to be started.

Syntax

[System.ComponentModel.DefaultValue("")]
[System.ComponentModel.Editor("System.Diagnostics.Design.WorkingDirectoryEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.NotifyParentProperty(true)]
[System.ComponentModel.RecommendedAsConfigurable(true)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Diagnostics.MonitoringDescription("The initial directory for this process.")]
public string WorkingDirectory { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

Note:

The ProcessStartInfo.WorkingDirectory property must be set if ProcessStartInfo.UserName and ProcessStartInfo.Password are provided. If the property is not set, the default working directory is %SYSTEMROOT%\system32.

If the directory is already part of the system path variable, you do not have to repeat the directory's location in this property.

The ProcessStartInfo.WorkingDirectory property behaves differently when ProcessStartInfo.UseShellExecute is true than when ProcessStartInfo.UseShellExecute is false. When ProcessStartInfo.UseShellExecute is true, the ProcessStartInfo.WorkingDirectory property specifies the location of the executable. If ProcessStartInfo.WorkingDirectory is an empty string, the current directory is understood to contain the executable.

Note:

When ProcessStartInfo.UseShellExecute is true, the working directory of the application that starts the executable is also the working directory of the executable.

When ProcessStartInfo.UseShellExecute is false, the ProcessStartInfo.WorkingDirectory property is not used to find the executable. Instead, its value applies to the process that is started and only has meaning within the context of the new process.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0