WPF C # Copy audio file to clipboard

I am trying to copy an audio file to the clipboard in C # using a file path. The problem I am running into is that either it is not copied or is not copied correctly because it cannot be pasted outside of the application.

This is how I try to copy it to the clipboard:

b_array = File.ReadAllBytes(fileLocation);
Clipboard.Clear();
Clipboard.SetAudio(b_array);

      

the fileLocation variable in my testing is roughly: C: \ Users \ ben \ Music \ Samples \ kick_05.wav

+3


source to share


1 answer


No need to read the contents of the file. You can add the file directly to the clipboard using SetFileDropList



StringCollection files = new StringCollection();
files.Add(fileLocation);
Clipboard.SetFileDropList(files);

      

+5


source







All Articles