C#调用浏览器是如何实现的呢?我们在实际的开发过程中会遇到这样的需求,那么来实现C#调用浏览器会用到什么方法呢?这里向你介绍了调用IE以及默认浏览器的具体操作。
C#调用浏览器之调用IE:
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.StartInfo.Arguments = " http://www.net0and1.com/";
myProcess.Start();
- 1.
- 2.
- 3.
- 4.
C#调用浏览器之调用默认浏览器:
string target= "http://www.net0and1.com";
//Use no more than one assignment when you test this code.
//string target = "ftp://ftp.microsoft.com";
//string target = "C:\\Program Files\\Microsoft Visual Studio\\INSTALL.HTM";
try
{
System.Diagnostics.Process.Start(target);
}
catch
(
System.ComponentModel.Win32Exception noBrowser)
{
if (noBrowser.ErrorCode==-2147467259)
MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
C#调用浏览器的操作就向你介绍到这里,希望对你了解和学习使用C#调用浏览器有所帮助。
【编辑推荐】