如何播放放置在 Resources 文件夹中的 SWF 文件

发布于 2024-11-27 04:13:41 字数 166 浏览 4 评论 0原文

我需要制作一个 Windows 应用程序,在加载时,我需要在 WebBrowser 中播放 Flash (.swf) 文件。但我可以直接从硬盘播放Flash文件到WebBrowser控件。这里我需要播放Resources文件夹中的.swf文件并将其加载到WebBrowser控件中。请帮忙。

提前致谢。

I need to make a Windows application in which, at loading time, I need to play a Flash (.swf) file in WebBrowser. But I can play the Flash file directly from hard disk to WebBrowser control. Here I need to play the .swf file in the Resources folder and load it in WebBrowser control. Please help.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水水月牙 2024-12-04 04:13:41
    System.Reflection.Assembly thisExe;
    thisExe = System.Reflection.Assembly.GetExecutingAssembly();
    System.IO.Stream file = thisExe.GetManifestResourceStream("Namespace.Filename");
    byte[] data = Properties.Resources.Filename;
    file.Read(data, 0, data.Length);
    System.Reflection.Assembly thisExe;
    thisExe = System.Reflection.Assembly.GetExecutingAssembly();
    System.IO.Stream file = thisExe.GetManifestResourceStream("Namespace.Filename");
    byte[] data = Properties.Resources.Filename;
    file.Read(data, 0, data.Length);
聽兲甴掵 2024-12-04 04:13:41

添加 flash(.swf ) 文件作为嵌入资源。

使用这个方法,它会如你所期望的那样工作。

   private void Form1_Shown(object sender, EventArgs e)
    {
        Stream sr = Assembly.GetExecutingAssembly().GetManifestResourceStream("namespace.file.swf");
        if (sr == null) return;
        var reader = new BufferedStream(sr);
        string tempfile = Path.GetTempFileName() + ".swf";
        var data = new byte[reader.Length];
        reader.Read(data, 0, (int)reader.Length);
        File.WriteAllBytes(tempfile, data);
        webBrowser1.Url = new Uri(tempfile);
    }

希望有帮助。

Add the flash(.swf ) file as embedded resource.

use this method it works as u expect.

   private void Form1_Shown(object sender, EventArgs e)
    {
        Stream sr = Assembly.GetExecutingAssembly().GetManifestResourceStream("namespace.file.swf");
        if (sr == null) return;
        var reader = new BufferedStream(sr);
        string tempfile = Path.GetTempFileName() + ".swf";
        var data = new byte[reader.Length];
        reader.Read(data, 0, (int)reader.Length);
        File.WriteAllBytes(tempfile, data);
        webBrowser1.Url = new Uri(tempfile);
    }

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文