locked
How do I reference project sound files when distributing? RRS feed

  • Question

  • I'm trying to add sound files to my project, but don't know how to reference them in the distributed code. On my testing machine, the files are inside the project's folder, and I access them in my code like this:

    SoundPlayer click = new SoundPlayer("C:\\VS2005\\MyProject\\Files\\click.wav");

    When distributing the application, it crashes when it can't find the file (of course). How do I resolve this, or make a global reference that'll work for the distribution?

    Thanks!
    Tuesday, June 24, 2008 4:49 AM

Answers

  •  gte351s wrote:
    I'm trying to add sound files to my project, but don't know how to reference them in the distributed code. On my testing machine, the files are inside the project's folder, and I access them in my code like this:

    SoundPlayer click = new SoundPlayer("C:\\VS2005\\MyProject\\Files\\click.wav");

    When distributing the application, it crashes when it can't find the file (of course). How do I resolve this, or make a global reference that'll work for the distribution?

    Thanks!

     

    Copy the file click.wav in the same directory where you have the application an reference it like this:

     

     

    Code Snippet

    SoundPlayer click = new SoundPlayer("click.wav");

     

     

    Tuesday, June 24, 2008 8:44 AM