How do I access a .avi stored as a resource?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fuzz13
    New Member
    • Jun 2010
    • 110

    How do I access a .avi stored as a resource?

    I'm trying to load a video file that I have added to my resources to play when a button is clicked. When the button is clicked the video should both load and play. Here is my code that fails:
    Code:
    video = new Video(properties.resources.koala_talk);
    this does not work. It says Arguement1 can not be converted from "byte[]" to "string" However if I hard code the directory it works:
    Code:
    video = new Video(@"C:\assignment3\koala_talk.avi");
    How do I reference the .avi that is located in my references and not hard code to the one not in my resources?


    Thanks for the help guys.
  • ZiadElmalki
    New Member
    • Sep 2010
    • 43

    #2
    You can add the file to the solution as an embedded resource. Add the avi to the soulution, right click on the file and select properties, in properties change the build action to embedded resource.

    You can use the GetManifestReso urceNames method to get the names of the embedded resources in a assembly.

    string[] names = Assembly.GetExe cutingAssembly( ).GetManifestRe sourceNames();

    Use the GetManifestReso urceStream with the resource name to get a stream.

    Assembly.GetExe cutingAssembly( ).GetManifestRe sourceStream("M yNameSpace.MyEm beddedResource. avi");

    Comment

    • Subin Ninan
      New Member
      • Sep 2010
      • 91

      #3
      try following code to extract resource form resource:

      Code:
      File.AppendAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\abc.avi", Properties.Resources.abc);

      Comment

      Working...