Tech Off Post

Single Post Permalink

View Thread: How to Embaded a File in the Solution as an Embaded Resource??
  • User profile image
    Minh

    I don't know how to make the Windows Medica control play a WAV resource, but use can use the following code to do that with the built-in SoundPlayer class:

                System.Reflection.Assembly execAssem = 
                    System.Reflection.Assembly.GetExecutingAssembly();
    
                string nameSpaceName = execAssem.GetName().Name;
                string resourceName = "ringin.wav";
    
                System.IO.Stream s = execAssem.GetManifestResourceStream(nameSpaceName + "." + resourceName);
    
                System.Media.SoundPlayer pl = new System.Media.SoundPlayer(s);
    
                pl.Play();
    
                s.Close();
    


    Peace, I'm out. Happy New Year!