ProcessStartInfo.WorkingDirectory 属性
定义
当 UseShellExecute 属性为 false 时,将获取或设置要启动的进程的工作目录。When the UseShellExecute property is false, gets or sets the working directory for the process to be started. 当 UseShellExecute 为 true 时,获取或设置包含要启动的进程的目录。When UseShellExecute is true, gets or sets the directory that contains the process to be started.
public:
property System::String ^ WorkingDirectory { System::String ^ get(); void set(System::String ^ value); };
public string WorkingDirectory { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string WorkingDirectory { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string WorkingDirectory { get; set; }
[System.ComponentModel.SettingsBindable(true)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string WorkingDirectory { get; set; }
[System.ComponentModel.SettingsBindable(true)]
public string WorkingDirectory { get; set; }
[System.ComponentModel.SettingsBindable(true)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string WorkingDirectory { get; set; }
member this.WorkingDirectory : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.WorkingDirectory : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.WorkingDirectory : string with get, set
[<System.ComponentModel.SettingsBindable(true)>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.WorkingDirectory : string with get, set
[<System.ComponentModel.SettingsBindable(true)>]
member this.WorkingDirectory : string with get, set
[<System.ComponentModel.SettingsBindable(true)>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.WorkingDirectory : string with get, set
Public Property WorkingDirectory As String
属性值
当 UseShellExecute 为 true 时,是包含要启动的进程的目录的完全限定名。When UseShellExecute is true, the fully qualified name of the directory that contains the process to be started. 当 UseShellExecute 属性为 false 时,则为要启动的进程的工作目录。When the UseShellExecute property is false, the working directory for the process to be started. 默认值为空字符串("")。The default is an empty string ("").
- 属性
注解
重要
WorkingDirectory如果 UserName 提供了和,则必须设置属性 Password 。The WorkingDirectory property must be set if UserName and Password are provided. 如果未设置该属性,则默认工作目录为%Systemroot%\system32If 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.
当为时, WorkingDirectory 属性的行为方式不同 UseShellExecute true UseShellExecute false 。The WorkingDirectory property behaves differently when UseShellExecute is true than when UseShellExecute is false. 当 UseShellExecute 为时 true , WorkingDirectory 属性将指定可执行文件的位置。When UseShellExecute is true, the WorkingDirectory property specifies the location of the executable. 如果 WorkingDirectory 是空字符串,则理解当前目录以包含可执行文件。If WorkingDirectory is an empty string, the current directory is understood to contain the executable.
备注
当 UseShellExecute 是 true 时,启动可执行文件的应用程序的工作目录也是该可执行文件的工作目录。When UseShellExecute is true, the working directory of the application that starts the executable is also the working directory of the executable.
当 UseShellExecute 为时 false , WorkingDirectory 不会使用属性来查找可执行文件。When UseShellExecute is false, the 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.