using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace dragDrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
object obj = e.Data.GetData(DataFormats.FileDrop);
Array files = obj as Array;
String s = "";
foreach (object o in files)
{
s = o as string;
}
s = s.Remove(0, s.LastIndexOf('\\') + 1);
listBox1.Items.Add(s);
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace dragDrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
object obj = e.Data.GetData(DataFormats.FileDrop);
Array files = obj as Array;
String s = "";
foreach (object o in files)
{
s = o as string;
}
s = s.Remove(0, s.LastIndexOf('\\') + 1);
listBox1.Items.Add(s);
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
}
}
}