开发者

How can I play a SWF file placed into Resources folder

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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜