简体   繁体   中英

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 issue I am running into is that it is either not copying, or not copying correctly because it can not be pasted outside of the application.

Here is how I am trying to copy it to the clipboard:

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

the variable fileLocation in my testing equals something like: C:\\Users\\ben\\Music\\Samples\\kick_05.wav

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM