本文介绍了如何在项目资源中存储Hta/HTML文件并在程序中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将.hta文件添加到我的应用程序的资源中,如下所示:

I have added an .hta file to my applciation's resources like so:

我想使用以下行显示此内容:

And I would like to display this by using the line:

Process.Start("explorer.exe", @"Path\To\File.hta");

当文件在我的系统上时有效,但是当我尝试使用以下命令显示.hta时:

This works when the file is on my system, but when I try displaying the .hta with:

Process.Start("explorer.exe", Properties.Resources.htatest);

我看到此错误:

是否可以在项目资源中存储.hta,然后从程序中调用它?

Is it possible to store an .hta in my project resources and then call it from the Program?

作为参考,这是.hta内部的代码:

For reference, here is the code which exists inside the .hta:

<html>
    <head>
        <title>IT Support - Message</title>
    </head>
    <script language = "VBScript">
        window.setInterval "setfocus()", 100
        Function setfocus
            window.focus()
        End Function
    </script>

    <body>
        <div style="margin-top:10%;">
            <h1 style="font-family:Segoe UI; color:#AF2B71; text-align: center; margin-top: 100pt">Message Heading</h1>
            <p style="font-family:Segoe UI; text-align: center"><strong/>This is a message which will be displayed to the user. </p>    
        </div>
    </body>
</html>

推荐答案

如注释中所述,必须将其添加为项目资源,然后复制到输出目录中.

As mentioned in the comments, this will have to be added as a project resource and then copied into the output directory.

Explorer无法提取嵌入到可执行文件中的文件.

Explorer has no way of extracting files which have been embedded into an executable.

这篇关于如何在项目资源中存储Hta/HTML文件并在程序中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:31