I created a drag and drop control within C# to allow people to drop files onto my form. Here's the problem I'm having, it works fine when it's being debugged; however when running my program in administrator mode it doesn't work. Is there any reason for this?
Here's my code:
private void panel1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
string startDir;
private void panel1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
dropZoneLabel.Text = "Adding files; please wait...";
foreach (string file in files)
{
bool isFolder = File.GetAttributes(file).HasFlag(FileAttributes.Directory);
if (isFolder)
{
//Scan the folder for all files
DirectoryOperations searchFolders = new DirectoryOperations();
DirectoryInfo di = new DirectoryInfo(file);
foreach (FileInfo dropfile in searchFolders.FullDirList(di, "*"))
{
listBox1.Items.Add(dropfile.Name);
}
startDir = di.FullName;
}
else
{
//It's a file so add it as normal
listBox1.Items.Add(file);
}
}
dropZoneLabel.Text = "Drop files or folders here";
}