C# cast audio form resources
i need some help regarding the following:
HomeArrayPicBox[i, j].Image = (Image)Properties.Resou开发者_如何学运维rces.ResourceManager.GetObject("Scan" + i);
SoundPlayer fire = new SoundPlayer(Properties.Resources.fire);
for the picbox i can load an image from resources using cast (Image).
i was wondering how to do this for audio i.e. some sort of (Audio)?
is this possible?
Yes, it's possible. Just use streams:
System.IO.Stream stream = Properties.Resources.ResourceManager.GetStream("resource_name");
System.Media.SoundPlayer player = new System.Media.SoundPlayer(stream);
精彩评论