How to copy and read audio files to the clipboard by VB.NET
Editor to share with you how VB.NET copies and reads audio files to the clipboard. I hope you will get something after reading this article. Let's discuss it together.
Sample code
Public Class Form1 'VB.Net copy reads the audio file and copies it to the clipboard Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim MyData As Byte () MyMyData = My.Computer.FileSystem.ReadAllBytes ("WindowsXP.wav") My.Computer.Clipboard.SetAudio (MyData) MessageBox.Show ("audio data VB.Net has been successfully copied to the clipboard!" , "51cto prompt", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show ("error copying audio data to the clipboard, please check if the audio file already exists?" , "51cto prompt", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub 'paste clipboard audio data and play Private Sub Button2_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try Dim MyData As Object MyMyData = My.Computer.Clipboard.GetData (DataFormats.WaveAudio) My.Computer.Audio.Play (MyData, AudioPlayMode.Background) Catch ex As Exception MessageBox.Show ("the specified audio data does not exist on the clipboard!" , "51cto hint", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub 'clear the audio data on the clipboard Private Sub Button3_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click My.Computer.Clipboard.Clear () End Sub End Class has finished reading this article, I believe you have some understanding of "how VB.NET copies and reads audio files to the clipboard", if you want to know more about it Welcome to follow the industry information channel, thank you for reading!