Hello,
I would use a variable to store the path, then use it in the button event.
This is because the button event arg is not the same as the drop method event args, you cannot reuse it.
private string _droppedFilePath;
public void DropBox_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
DropBox.Items.Clear();
string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[];
foreach (string droppedFilePath in droppedFilePaths)
{
ListBoxItem fileItem = new ListBoxItem();
fileItem.Content = System.IO.Path.GetFileNameWithoutExtension(droppedFilePath);
fileItem.ToolTip = droppedFilePath;
DropBox.Items.Add(fileItem);
_droppedFilePath = droppedFilePath;
}
}
}
private void CleanButton_Click(object sender, RoutedEventArgs e)
{
string CC= Convert.ToString("C://Users//James//Desktop//VB//Pictures");
System.IO.File.Copy(_droppedFilePath, CC);
}