gpt4 book ai didi

c# - 如何调用IE打开本地html文件?

转载 作者:太空宇宙 更新时间:2023-11-03 18:49:50 25 4
gpt4 key购买 nike

我正在使用 VSTS 2008 + C# + .Net 2.0。我想调用 IE 来打开位于当前可执行文件的 pages 子文件夹下的 html 文件。

由于我的程序可能运行在Windows Vista下,所以我想在管理权限下调用IE(Run As Administrator)。

有什么代码可以引用吗?我对如何编写可移植代码特别感兴趣,它可以在 Windows Vista 和 Windows XP 上运行(我认为 Windows XP 没有以管理员身份运行的功能)

编辑 1:

我正在使用以下代码,但没有打开 UAC(用户访问控制)提示消息框让我选择继续以管理员身份运行。有什么想法吗?

    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.Verb = "RunAs";
startInfo.Arguments = @"C:\test\default.html";
Process.Start(startInfo);

提前致谢,乔治

最佳答案

要使用相对路径,请查看 GetFullPath method .

string fullPath = Path.Combine(Path.GetFullPath(@".\dir\dir2"), "file.html");
System.Diagnostics.Process.Start("iexplore.exe", fullPath);

关于c# - 如何调用IE打开本地html文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1117842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com