Solorzano Jose
Solorzano Jose

Reputation: 632

Audio pack into exe

Is there a way to include an audio file, like the images can be done, into the output exe file in .NET ? c#

I've been looking around and wow, this apparently isn't used that much?

Upvotes: 0

Views: 419

Answers (1)

Ronnix
Ronnix

Reputation: 310

Add your file to the resources of the assembly.

  1. Open properties of your project.
  2. Go to the "Resources" tab. Click Add Resource -> Add Existing File.
  3. Change the name of this resource if you want.

Now you can play it like this (provided that I named the resource as MyWavResource):

System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.MyWavResouce);
player.Play();

Upvotes: 2

Related Questions