Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .Net Drag and Drop

.Net Drag and Drop

Scheduled Pinned Locked Moved C#
csharpquestion
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sergio Paque
    wrote on last edited by
    #1

    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 :)

    C 1 Reply Last reply
    0
    • S Sergio Paque

      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 :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      S 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        S Offline
        S Offline
        Sergio Paque
        wrote on last edited by
        #3

        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.

        M V 2 Replies Last reply
        0
        • S Sergio Paque

          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.

          M Offline
          M Offline
          Mark Greenwood
          wrote on last edited by
          #4

          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 }

          1 Reply Last reply
          0
          • S Sergio Paque

            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.

            V Offline
            V Offline
            Vikram A Punathambekar
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • V Vikram A Punathambekar

              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.

              S Offline
              S Offline
              ScottM1
              wrote on last edited by
              #6

              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.

              V 1 Reply Last reply
              0
              • S ScottM1

                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.

                V Offline
                V Offline
                Vikram A Punathambekar
                wrote on last edited by
                #7

                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.

                S 1 Reply Last reply
                0
                • V Vikram A Punathambekar

                  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.

                  S Offline
                  S Offline
                  ScottM1
                  wrote on last edited by
                  #8

                  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.

                  V 1 Reply Last reply
                  0
                  • S ScottM1

                    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.

                    V Offline
                    V Offline
                    Vikram A Punathambekar
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups