- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to run an external application through a C# application?
An external application can be run from a C# application using Process. A process is a program that is running on your computer. This can be anything from a small background task, such as a spell-checker or system events handler to a full-blown application like Notepad etc.
Each process provides the resources needed to execute a program. Each process is started with a single thread, known as the primary thread. A process can have multiple threads in addition to the primary thread. Processes are heavily dependent on system resources available while threads require minimal amounts of resource, so a process is considered as heavyweight while a thread is termed as a lightweight process. Process is present in System.Diagnostics namespace.
Example to run 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(); } } }
The above output shows the console application opened Notepad with the name DemoText provided in the arguments.
Example to run browser from C# application
using System; using System.Diagnostics; namespace DemoApplication{ class Program{ static void Main(){ Process.Start("https://www.google.com/"); Console.ReadLine(); } } }
The above code will open the browser and redirect to www.google.com.