Training
Module
Get started with file input and output - Training
Learn how to manage local files and directories using the System.IO classes, and how to store and retrieve C# objects using CSV files and the StreamReader and StreamWriter classes.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article provides supplementary remarks to the reference documentation for this API.
The ProcessStartInfo class specifies a set of values that are used when you start a process.
Setting the UseShellExecute property to false
enables you to redirect input, output, and error streams.
The word "shell" in this context (UseShellExecute
) refers to a graphical shell (similar to the Windows shell) rather than command shells (for example, bash
or sh
) and lets users launch graphical applications or open documents.
Note
UseShellExecute must be false
if the UserName property is not null
or an empty string, or an InvalidOperationException will be thrown when the Process.Start(ProcessStartInfo) method is called.
When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the Process object. When UseShellExecute is false
, you can start only executables by using the Process object.
Note
UseShellExecute must be true
if you set the ErrorDialog property to true
.
The WorkingDirectory property behaves differently depending on the value of the UseShellExecute property. When UseShellExecute is true
, the WorkingDirectory property specifies the location of the executable. If WorkingDirectory is an empty string, it's assumed that the current directory contains the executable.
When UseShellExecute is false
, the WorkingDirectory property is not used to find the executable. Instead, it is used only by the process that is started and has meaning only within the context of the new process. When UseShellExecute is false
, the FileName property can be either a fully qualified path to the executable, or a simple executable name that the system will attempt to find within folders specified by the PATH
environment variable. The interpretation of the search path depends on the operating system. For more information, enter HELP PATH
or man sh
at a command prompt.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Training
Module
Get started with file input and output - Training
Learn how to manage local files and directories using the System.IO classes, and how to store and retrieve C# objects using CSV files and the StreamReader and StreamWriter classes.
Events
Sep 19, 1 AM - Sep 19, 1 AM
.NET 10 launches at .NET Conf 2025! Tune in with the .NET community to celebrate and learn about the new release on November 11 - 13.
Save the dateAsk Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in