AllowDrop is enabled on both Form1 and textBox1. The events are enabled and start when DragDrop and DragEnter are performed. I've already tried rearranging the code so that textBox1_DragEnter is located before textBox1_DragDrop, but that doesn't work. What is wrong with this code?
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
FileInfo fi = new FileInfo((string)e.Data.GetData(DataFormats.FileDrop));
byte[] ba = Encoding.Default.GetBytes(fi.OpenText().ToString().ToCharArray());
textBox1.Text = ba.ToString();
}
private void textBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string file = (string)e.Data.GetData(DataFormats.FileDrop);
if (Path.GetExtension(file) != "dat")
{
s = "broken file";
}
}
}