Home > Backend Development > C#.Net Tutorial > How to run external application through C# application?

How to run external application through C# application?

王林
Release: 2023-09-09 15:05:01
forward
1511 people have browsed it

You can run external applications from a C# application using Process. A process is a program that runs on your computer. This can be anything from a small background task (such as a spell checker or a system event handler) to a full-blown application (such as Notepad, etc.).

Each process provides the resources needed to execute the program. Every process is started by a thread, called the main thread. A process can have multiple threads in addition to the main thread. Processes heavily depend on the available system resources, while threads require minimal resources, so processes are considered heavyweight processes, while threads are called lightweight processes. The process exists in the System.Diagnostics namespace.

Example of running Notepad from C# application

using System;
using System.Diagnostics;
namespace DemoApplication{
   class Program{
      static void Main(){
         Process notepad = new Process();
         notepad.StartInfo.FileName = "notepad.exe";
         notepad.StartInfo.Arguments = "DemoText";
         notepad.Start();
         Console.ReadLine();
      }
   }
}
Copy after login

How to run external application through C# application?

The above output shows that the console application opens Notepad which The name is the DemoText provided in the parameter.

Example of running browser from C# application

using System;
using System.Diagnostics;
namespace DemoApplication{
   class Program{
      static void Main(){
         Process.Start("https://www.google.com/");
         Console.ReadLine();
      }
   }
}
Copy after login

The above code will open the browser and redirect to www.google.com.

The above is the detailed content of How to run external application through C# application?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template