c# - Why some directories i can't drag and drop on listBox1? -
this path of folder images inside i'm trying drag , drop listbox1:
c:\users\chocolade1972\appdata\local\mws\my weather station\images
but if drag folder in c:\ example c:\images drag fine listbox1.
when drag user...directory see black symbol can't drop in.
private void listbox1_dragdrop(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { string[] files = (string[])e.data.getdata(dataformats.filedrop); label6.text = files.length.tostring(); filescount = files.length-1; beginconvertiontoolstripmenuitem.enabled = true; (int = 0; < files.length; i++) { fileinfo fi = new fileinfo(files[i]); if (listbox1.items.contains(fi.fullname)) { } else { string directoryname = fi.directoryname; string[] filesextension = directory.getfiles(directoryname).select(p => path.getextension(p)).distinct().orderby(p => p).toarray(); (int d = 0; d < filesextension.length; d++) { if (fi.extension.tolower() == filesextension[d]) { listbox1.items.add(fi.fullname); } } } } this.select(); } }
and drag on event:
private void listbox1_dragover(object sender, drageventargs e) { if (e.data.getdatapresent(dataformats.filedrop)) { string[] files = (string[])e.data.getdata(dataformats.filedrop); bool bfound = false; (int = 0; < files.length; i++) { fileinfo fi = new fileinfo(files[i]); string directoryname = fi.directoryname; string[] filesextension = directory.getfiles(directoryname).select(p => path.getextension(p)).distinct().orderby(p => p).toarray(); (int d = 0; d < filesextension.length; d++) { if (fi.extension.tolower() == filesextension[d]) { bfound = true; } } } if (bfound) e.effect = dragdropeffects.copy; else e.effect = dragdropeffects.none; } else e.effect = dragdropeffects.none; }
Comments
Post a Comment