1 out of 1 rated this helpful - Rate this topic

ProcessStartInfo.WorkingDirectory Property

Gets or sets the initial directory for the process to be started.

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)
[SettingsBindableAttribute(true)]
[TypeConverterAttribute("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string WorkingDirectory { get; set; }

Property Value

Type: System.String
The fully qualified name of the directory that contains the process to be started. The default is an empty string ("").
Important note Important

   The WorkingDirectory property must be set if UserName and 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 WorkingDirectory property behaves differently when UseShellExecute is true than when UseShellExecute is false. When UseShellExecute is true, the WorkingDirectory property specifies the location of the executable. If WorkingDirectory is an empty string, the current directory is understood to contain the executable.

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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Eugene Shpungin
I Completely agree. The property semantics should not change conditionally.
Eugene Shpungin
I Completely agree. The property semantics should not change conditionally.
Change in use for WorkingDirectory when UseShellExecute = false
Ah that's terrible. Wouldn't it be preferable to make two separate properties here rather than use one for two different purposes. I got truly stuck on this for hours today... and working directory looks so obviously like a simple property one wouldn't normally check out it's definition.