How to Store Hta/Html File in Project Resources and Use in Program

点点圈 提交于 2019-12-13 21:18:44

问题


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");

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

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

I see this error:

There is no program associated to perform the requested action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.

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

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>

回答1:


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

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



来源:https://stackoverflow.com/questions/37965304/how-to-store-hta-html-file-in-project-resources-and-use-in-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!