Very rusty native C++ programmer here with pretty much zero experience with Visual Studio. I’m just trying to knock together a simple program that will change the extension of files that are dropped onto it but I’ve run into the problem in the title which occurs when the DragDrop event is fired upon the file being dropped onto the form. It gets so far as the following line:
String ^sOldName = (String ^) e->Data->GetData(DataFormats::FileDrop, false);
then throws up the exception and breaks out of the event. I ripped a lot of this code from all over the place so there’s a good chance it’s just an old-fashioned syntax or something.
I really appreciate any help in this. Thanks.
There are two issues here.
First, you can specify
true, notfalse, to allow theGetDatacall to automatically handle the format conversion for you. If the data is in the incorrect format, then you won’t be able to convert the data to aString^.Second, the data from a shell file drop is typically an
array<String^>^, notString^.Try the following: