Skip to content

Instantly share code, notes, and snippets.

Last active September 28, 2019 03:25
What would you like to do?
Woohoo Winforms Lesson
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WoohooWinform
public partial class Form1 : Form
public Form1()
private void button1_Click(object sender, EventArgs e)
// Find File Path to Main Directory (Contains Main Program and Additional Files)
string pathToDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
// Create SoundPlayer Object Which Will Play Our WAV File
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
// Tell The SoundPlayer Object Where Our WAV File is Located
player.SoundLocation = pathToDirectory + @"\woohoo.wav";
// Say Woohoo!
private void label1_Click(object sender, EventArgs e)
private void Form1_Load(object sender, EventArgs e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment