AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
U filedrop3/18/2023 ![]() I've tried: var ob = e.Data.GetData(typeof(object)) Īnd it still returns null when you include the recycle bin. RecycleBin and Desktop are special directories and I assume that DrapDrop cannot handle them so the conversion fails and it returns null. You're still asking GetData to convert to DataFormats.FileDrop but it can't. You're still attempting to convert it into DataFormats.FileDrop and that's where it's returning null. Today you're attempting to convert to object and are getting the same error in the same place. Yesterday you wanted to convert to a string array (DataFormat.FileDrop) and it would fail. It states that it will attempt to convert it to whatever format you require. ![]() Now loop over the directories list which is guaranteed to have valid string items String DroppedDirectories = (string) e.Data.GetData(DataFormats.FileDrop,false) įoreach(string dir in DroppedDirectories) if (e.Data.GetData(DataFormats.FileDrop, false) != null) If you didn't like the try catch around the ListViewItem creation you can always do as you've done above check for null first. You're getting a null back as per the documentation that Abion47 linked for you.Ī string is a nullable type so the answer given yesterday still holds. You will need to check your list items before you do anything with them. I'm sure we've already, pretty much answered this for you Yesterday. Object rawArray=(object)e.Data.GetData(DataFormats.FileDrop, false) įoreach (var s in rawArray)\\System.NullRefferenceException occurs. This code still throws System.NullRefferenceException: private void Directories_ListView_DragDrop(object sender, DragEventArgs e) I assume i have to check every object and eliminate the null ones (then i can cast an array without Null-objects to string and i get proper paths and no NRexceptions during further processing). ![]() My question is what is the exact return value of Get data method below (when i drag and drop few files in one moment) ?: Data.GetData(DataFormats.FileDrop, false) It works fine, but when i drag and drop "M圜omputer" or something from Webbrowser, my program throws nullfrefferenceexception. I can also cast this and i get paths of all dragged and dropped files: string DroppedDirectories = (string)e.Data.GetData(DataFormats.FileDrop, false) In my Drag and drop Listview i am collecting the dragged and dropped files by: var objects=Data.GetData(DataFormats.FileDrop, false)
0 Comments
Read More
Leave a Reply. |