【问题标题】:Is there any explorer.exe problem in windows 7?Windows 7 中是否有任何 explorer.exe 问题?
【发布时间】:2010-03-25 23:41:11
【问题描述】:
s += "<p style=\"text-align: left;\"><a href=\"javascript:window.print()\">PRINT</a></p>";
System.IO.File.WriteAllText(@"CheckForm.html", s);
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "explorer.exe";
startInfo.Arguments = "CheckForm.html";
System.Diagnostics.Process.Start(startInfo);

当我尝试在 Windows 7 中打开我的 C# windows 应用程序时遇到问题,否则没有问题。

我无法使用上述代码在 Windows 7 中打开 explorer.exe。

有什么建议吗?

【问题讨论】:

  • 为什么要在 Windows 资源管理器中打开网页?
  • 因为每台电脑都有资源管理器。
  • 绝对不是每台电脑。和 Windows 资源管理器!= Internet Explorer。详情见我的回答。
  • 实际上,您的代码在 Windows 7 上适用于我。HTML 文档在我的默认浏览器中打开。你说的麻烦到底是什么?您是否尝试过为您的文档使用绝对路径?
  • 当我尝试上面的代码时,Internet Explorer 没有打开。

标签: c# windows-7 explorer


【解决方案1】:

要打开 HTML 文件,您只需调用 Process.Start 并提供文件路径,如下所示:

Process.Start(@"CheckForm.html");

这将在默认程序中打开文件。 (通常是 IE 或 Firefox)

【讨论】:

  • +1,但是,只是附加说明:这仅在 startInfo.UseShellExecute (msdn.microsoft.com/en-us/library/…) 设置为 true 时才有效,幸运的是,这是默认设置,所以在上面的示例中你不要不用担心。
  • 那么工作的应该是什么? System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "explorer.exe"; startInfo.Arguments = "CheckForm.html"; System.Diagnostics.Process.Start(startInfo); StartInfo.UseShellExecute = false;这个?
  • 你应该写Process.Start(@"CheckForm.html");
【解决方案2】:

explorer.exe 是 Windows 资源管理器或桌面系统。您可能想要打开 Internet Explorer,其进程名称将是 iexplore.exe

Windows Explorer 之前已与 Internet Explorer 集成,因此 - 根据您输入的路径 - 程序会切换到所需的应用程序。 IE 用于 url,Windows 资源管理器用于本地路径。这可能就是它以前起作用的原因。

但是我认为在 Vista 中,集成被松散了,所以这将不再起作用。

【讨论】:

  • explorer.exe 也是外壳。所以@sml贴的示例代码没有错。
  • 是的,探险家扮演着很多角色。但从代码来看,他似乎更想打开 Internet Explorer,而不是 html 文件的默认应用程序。
  • 嗯,从 cmets 看来他想要 IE,但从代码中他会得到与 .html 文件关联的应用程序。
  • 嗯,我的回答是基于他将 explorer 与 iexplore 混为一谈的想法:P
  • 使用ieplore.exe 需要传递完整路径作为参数,即startInfo.Arguments = Path.Combine(Directory.GetCurrentDirectory(), "CheckForm.html");
猜你喜欢
  • 1970-01-01
  • 2011-09-24
  • 2010-11-29
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
  • 2011-04-01
  • 2010-10-28
  • 2011-07-02
相关资源
最近更新 更多