Set the Form property allowDrop = True;
In the Form event C # tutorial
private void Form1_DragDrop(object sender, DragEventArgs e)
{
string localFilePath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();//Full path of the file
GetExtension(localFilePath);//file suffix name
if (extension == ".cbd")
{
//todo you code
}
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
string localFilePath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
string extension = System.IO.Path.GetExtension(localFilePath);
if (string.Compare(extension, ".cds", true) == 0)
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.None;
}
}