Listview DragDrop Visual Themes error...
-
I am working on a FTP client that works great but when I use file drop from windows explorer the application crashes and ends. The error breaks at the Application.Run(new Mainform); and gives me the following error: "An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll Additional information: External component has thrown an exception." If I put a try catch around that I get this error message Exception.Message = "External component has thrown an exception." I am using Visual Themes and are sure that that is the problem.
[STAThread] static void Main() { try { Application.EnableVisualStyles(); Application.DoEvents(); Application.Run(new MainForm()); } catch(Exception Ex) { MessageBox.Show(Ex.Message,"Runtime Error.",MessageBoxButtons.OK,MessageBoxIcon.Error); } }
When I take the EnableVisualStyles(); out it works fine. Also when I do a file drop, my progressbar losses the Visual Theme. How do I get around this and still use the Visual Themes? Here is my Drop code:private void listView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if( e.Data.GetDataPresent(DataFormats.FileDrop, false)) { string[] files_str = (string[])e.Data.GetData(DataFormats.FileDrop); foreach(string file_str in files_str) { FileInfo droppedFile = new FileInfo(file_str); if(droppedFile.Exists) { UploadFile(droppedFile); } else if(droppedFile.Directory.Exists) { DirectoryInfo droppedDirectory = new DirectoryInfo(file_str); if(droppedDirectory.Exists) { UploadDirectoryChanges(droppedFile.Directory); } } else { MessageBox.Show(file_str +"\nis not recognized as a valid file drop.","Unsupported File drop!",MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
Leon v Wyk