C# open url in default browser in c# windows application(Winforms Process.Start)
Click some hyperlink text on the software interface to open a web page in the default browser. How should this function be implemented in C# Winforms development? The method is very simple. C# provides an open method Process.Start(), which can be achieved by passing the URL to the opened method.
Some software has a lot of hyperlink text, click one to open a webpage, how is this achieved? In fact, no matter how many hyperlinks, you can use the Process.Start() method. Just click a link and pass a URL to it.
1. C# open url in default browser directly(Open url by C# process start)
Or System.Diagnostics.Process.Start("IEXPLORE.EXE", "Url");
IEXPLORE.EXE is not case-sensitive, and it is not necessary to write .exe, that is, iexplore.
Tip: If the code is to be encrypted with an encryption tool, the web page cannot be opened through the form of System.Diagnostics.Process.Start("url"); after encryption. The namespace must be referenced(i.e. using System.Diagnostics;), the code write the class directly, that is, Process.Start("url"); to open the web page.
2. C# open url in default browser by creating a new Process object
For ease of use, we encapsulate the code in a method, the code is as follows:
/// Open url in c# windows application
/// <param name="url">URL of the page to open</param>
public void OpenUrl(string url)
Process pro = new Process();
pro.StartInfo.FileName = "iexplore.exe";
pro.StartInfo.Arguments = url;
- Winforms dynamically add controls with code
- C# get url, domain, absolute, relative and physical
- C# label control, with winforms label transparent ba
- C# Winforms textbox focus(2 methods)
- Visual studio change curly brace style(highlight bra
- C# Winforms Resources add, modify and delete
- C# Winforms panel border, with color, style, thickne
- C# Winforms listview show table(adaptive column widt