.Net Drag and Drop
-
Hi, i'm currently working with drag and drop between windows explorer and a form using the .net drag and drop. I have a file and a directory with the same name and i want to drop one of them from explorer to my form. Is there a way of telling whether the item i'm dropping into the form is a file or a directory? Thanks in advance :)
-
Hi, i'm currently working with drag and drop between windows explorer and a form using the .net drag and drop. I have a file and a directory with the same name and i want to drop one of them from explorer to my form. Is there a way of telling whether the item i'm dropping into the form is a file or a directory? Thanks in advance :)
Doesn't it deliver a path ? File.Exists will tell you.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Doesn't it deliver a path ? File.Exists will tell you.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
yep, it delivers the path, but the problem arises when there's both a file and a directory with exactly the same name. If I use File.Exists and I'm actually dropping the directory then I would get the wrong item.
-
yep, it delivers the path, but the problem arises when there's both a file and a directory with exactly the same name. If I use File.Exists and I'm actually dropping the directory then I would get the wrong item.
You will need to load the file in as a FileInfo and then look at the attributes to see if it's a directory or not...
FileInfo f = new FileInfo(strFileName); if ((f.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { // Delete it } else { // Ignore it - or whatever }
-
yep, it delivers the path, but the problem arises when there's both a file and a directory with exactly the same name. If I use File.Exists and I'm actually dropping the directory then I would get the wrong item.
You CANNOT have a file and a folder with the same name in the same location. However, as already suggested, you can use the attributes to find out if the entity in question is a directory.
Cheers, Vıkram.
After all is said and done, much is said and little is done.
-
You CANNOT have a file and a folder with the same name in the same location. However, as already suggested, you can use the attributes to find out if the entity in question is a directory.
Cheers, Vıkram.
After all is said and done, much is said and little is done.
-
This is true, I never knew that, I just tried it. But surely your file would have an extension which makes its filename different to the folder's filename anyway.
There are 10 types of people in the world, those who understand binary and those who dont.
smyers wrote:
But surely your file would have an extension which makes its filename different to the folder's filename anyway.
You can have a file without an extension. You can equally well have a folder with an 'extension'.
Cheers, Vıkram.
After all is said and done, much is said and little is done.
-
smyers wrote:
But surely your file would have an extension which makes its filename different to the folder's filename anyway.
You can have a file without an extension. You can equally well have a folder with an 'extension'.
Cheers, Vıkram.
After all is said and done, much is said and little is done.
True that. What I meant though was that your file will more than likely(almost definately) have an extension and your folder will not. Why would anyone create a file without an extension or a folder with one for that matter.
There are 10 types of people in the world, those who understand binary and those who dont.
-
True that. What I meant though was that your file will more than likely(almost definately) have an extension and your folder will not. Why would anyone create a file without an extension or a folder with one for that matter.
There are 10 types of people in the world, those who understand binary and those who dont.
We're splitting hairs, but as a developer, I would want my code to be as robust as it should. I wouldn't ignore scenarios that are unlikely. One man's food is another's poison.
Cheers, Vıkram.
After all is said and done, much is said and little is done.