Hello,

I have successfully added a wav file or audio file to my program, the problem is, i sent an email to my friend of the exe application but the wav file does not come with, how do i accomplish this if the wav file does not compile with the application together? do i save it in the same folder and change the directory? do i put in the C# code to make a directory and save the audio file to a new directory etc?

Thank you in advance, below is my program if you would like to view it.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string txt1 = textBox1.Text;
            MessageBox.Show(txt1);

            switch (textBox1.Text.ToString())
            {
                case "Steven":
                    System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\loktar.wav");
                    simplesound.Play();
                    MessageBox.Show("why you got to bring my name in the picture?!");
                    break;

            }
            if (textBox1.Text == "Wade")
            {
                MessageBox.Show("Wade is a funny name!!");
                MessageBox.Show("ERROR cannot define what Wade is because it is too weird");
                System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\loktar.wav");
                simplesound.PlayLooping();
            }
            if (textBox1.Text == "WADE")
            {
                MessageBox.Show("WADE is a funny name!!");
                MessageBox.Show("ERROR cannot define what WADE is because it is too weird");
                System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\loktar.wav");
                simplesound.PlayLooping();
            }
            if (textBox1.Text == "wade")
            {
                MessageBox.Show("wade is a funny name!!");
                MessageBox.Show("ERROR cannot define what wade is because it is too weird");
                System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\loktar.wav");
                simplesound.PlayLooping();
            }
            else
            {
                MessageBox.Show("Hello " + txt1);
            }



            //textBox1.Text = "Daboo";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\daboo.wav");
            simplesound.Play();          
        }

        private void button4_Click(object sender, EventArgs e)
        {
            System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\zugzug.wav");
            simplesound.Play();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

    }
}

Hi,
I think you cannot merge your sound file into exe file by the way of your compilation. but can add these files in deployment. Also instead of giving the Full Path ("c:\additional\loktar.wav") , u can give the relative path. First you place the wav files (or directory) to the directory where your exe file resides. Now you can use Application.StartupPath to refer the directory where executable resides.

System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer( Application.StartupPath  + "\\additional\\zugzug.wav");
simplesound.Play();

Instead of

System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"c:\additional\zugzug.wav");
simplesound.Play();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.