How to use relative path to Resources folder in C# Window Form application?

前端 未结 1 1376
情话喂你
情话喂你 2021-01-07 05:40

I want to play sound when the window form loaded,

SoundPlayer sound = new SoundPlayer( @\"song.mp3\" );
sound.Play();

When distributing thi

1条回答
  •  佛祖请我去吃肉
    2021-01-07 05:51

    Create a resources bundle and store it in the bundle, and just reference the sound file within the bundle.

    IE: when creating a winforms project by default, you'll see a Resources.resx file in the Properties folder. Add a resource there, and then reference it from code:

    Properties.Resources.String1;
    

    0 讨论(0)
提交回复
热议问题