Skip to content

Instantly share code, notes, and snippets.

@IT-Delinquent
Created July 27, 2021 10:58
Show Gist options
  • Select an option

  • Save IT-Delinquent/99ae1fb24a9ad5bc9e60fffd7239201f to your computer and use it in GitHub Desktop.

Select an option

Save IT-Delinquent/99ae1fb24a9ad5bc9e60fffd7239201f to your computer and use it in GitHub Desktop.
saveMusicToDiskWPF
public static void SaveMusicToDisk(){
//This sets up a new temporary file in the %temp% location called "backgroundmusic.wav"
using (FileStream fileStream = File.Create(Path.GetTempPath() + "backgroundmusic.wav")){
//This them looks into the assembly and finds the embedded resource
//inside the WPF project, under the assets folder
//under the sounds folder called backgroundmusic.wav
//PLEASE NOTE: this will be different to you
Assembly.GetExecutingAssembly().GetManifestResourceStream("WPF.Assets.Sounds.backgroundmusic.wav").CopyTo(fileStream);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment