C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,219 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I'm using Visual Studio Community 2019 Version 16.8.4 with .NET Framework 4.8.04084 on a laptop computer developing a C# windows form program.
I want to open a new Firefox window from my program.
I can open a new tab in an existing Firefox window using the following code:
private void CreateNFLStats_Click(object sender, EventArgs e)
{
//// Got this here: https://learn.microsoft.com/en-us/troubleshoot/dotnet/csharp/start-internet-browser
string target = "https://www.nfl.com/stats/team-stats/offense/passing/2021/reg/all";
try
{
System.Diagnostics.Process.Start("firefox.exe", target);
Application.Exit();
}
catch (System.ComponentModel.Win32Exception noBrowser)
{
if (noBrowser.ErrorCode == -2147467259)
MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}
}
How do I open the URL in a new Firefox Window?
Any help would be gratefully appreciated.
Thanks,
Tony
Try this:
Process.Start( "firefox.exe", "-new-window " + target )
Excellent Viorel!
That worked perfectly.
Thanks for your help.
Tony