我想知道是否有可能通过单击Winform应用程序中的按钮来刷新网页。
我有一个表单,当按下一个按钮时会启动一个过程,并在浏览器窗口中显示一个网页,并且我想在按下另一个按钮而不是打开另一个窗口时刷新它。
是否可以?
我已经检查了这个问题stackoverflow,但是因此它刷新了我已经调用的文件?
我像这样启动网页:
string path = Directory.GetParent(Directory.GetCurrentDirectory())
.Parent.FullName;
string target = @"DashBoard.html";
string finalPath = Path.Combine(path, target);
System.Diagnostics.Process.Start(finalPath);
我已经检查了该问题中的一种解决方案,并且我理解了,但是我找不到的是是否有一种方法可以在所有浏览器中使用。
有什么提示吗?
我能够找到一个解决方案,这是我创建的功能
private void RefreshPage()
{
int count = 0;
IntPtr[] explorerHandle = new IntPtr[4] {
FindWindow(null, "DashBoard - Google Chrome"),
FindWindow(null, "DashBoard - Internet Explorer"),
FindWindow(null, "DashBoard - Opera"),
FindWindow(null, "DashBoard - Firefox")
};
foreach (IntPtr value in explorerHandle)
{
if (value != IntPtr.Zero)
{
count++;
SetForegroundWindow(value);
SendKeys.Send("{F5}");
}
}
if(count == 0)
System.Diagnostics.Process.Start("http://localhost:9000/DashBoard.html");
}
谢谢你的帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句