dynamically load resource file

Viewed 4580

I want to dynamically load a resource file.

If i do it statically, it obviously works well:

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

This loads and plays the resource _88.

However, I want this to be dynamically,

I have a variable 'num' which can be any number from 1-90, and i want to load the resource related to that number.

So I create another variable called 'soundURL' which looks like:

var soundURL = "_" + num;

But when I use that with the previous it obviously doesnt work:

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

How can I overcome this?

3 Answers
Related