form1中namespce里的代码如下
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        string folder = textBox1.Text;
        string folderPath = @folder; // 指定音频文件所在的文件夹路径
        OpenRandomFile(folderPath);
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    }
    //实际是随机打开一个文件,鉴于VS内置的库不能播放除了wav以外的音频
    private void OpenRandomFile(string folderPath)
    {
        if (!Directory.Exists(folderPath))
        {
            MessageBox.Show("指定的文件夹不存在,请检查路径是否正确。");
            return;
        }
        var files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
        if (files.Length == 0)
        {
            MessageBox.Show("文件夹为空或没有可访问的文件。");
            return;
        }
        Random random = new Random();
        int index = random.Next(files.Length);
        string filePath = files[index];
        try
        {
            System.Diagnostics.Process.Start(filePath);
        }
        catch (Exception ex)
        {
            MessageBox.Show($"无法打开文件: {ex.Message}");
        }
    }
}实际是随机打开一个文件,鉴于VS内置的库不能播放除了wav以外的音频
效果如图

这里的文件夹地址是直接Ctrl+Shift+C复制过来的,注意要去掉引号
exe的链接如下
链接:https://pan.baidu.com/s/105w5fij6kkrUoWcjMuiBWA?pwd=tdo7 
 提取码:tdo7





