我将我的文件发送到剪贴板,我想复制所有文件指定路径,例如一键单击桌面,文件,例如但我有问题我不从列表框中获取所有文件,我不复制指定路径我如何复制所有文件……
public partial class Form1 : Form
{
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SetClipboardViewer(IntPtr hWnd);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
IntPtr SonrakiClipboardOgesi;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SonrakiClipboardOgesi = SetClipboardViewer(this.Handle);
}
protected override void WndProc(ref Message m)
{
int WM_DRAWCLIPBOARD = 0x0308;
int WM_CHANGECBCHAIN = 0x030D;
if (m.Msg == WM_DRAWCLIPBOARD)
{
ClipboardRead();
SendMessage(SonrakiClipboardOgesi, m.Msg, m.WParam, m.LParam);
}
else if (m.Msg == WM_CHANGECBCHAIN)
{
if (m.WParam == SonrakiClipboardOgesi)
{
SonrakiClipboardOgesi = m.LParam;
}
else
{
SendMessage(SonrakiClipboardOgesi, m.Msg, m.WParam, m.LParam);
}
}
base.WndProc(ref m);
}
private void ClipboardRead()
{
StringCollection col = new StringCollection();
col = Clipboard.GetFileDropList();
for (int i = 0; i < col.Count; i++)
{
listBox1.Items.Add(col[i]);
}
listBox1.SelectionMode = SelectionMode.MultiSimple;
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox1.SetSelected(i, true);
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
ChangeClipboardChain(this.Handle, SonrakiClipboardOgesi);
}
private void button1_Click(object sender, EventArgs e)
{
// ı make a with click copy within listbox files specified path
//What code I should write here
}
}