简体   繁体   English

WPF C#将音频文件复制到剪贴板

[英]WPF C# Copy Audio File To Clipboard

I am trying to copy an audio file to the clipboard in C# using a file path. 我正在尝试使用文件路径将音频文件复制到C#中的剪贴板。 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 我的测试中的变量fileLocation等于: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 您可以使用SetFileDropList将文件直接添加到剪贴板

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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