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. folder and file difference

folder and file difference

Scheduled Pinned Locked Moved C#
csharptutorial
4 Posts 3 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.
  • C Offline
    C Offline
    chandler83
    wrote on last edited by
    #1

    how to identify whether a dropped object in my application is a file or a folder. atpresent, i am using File.Exists method and Directory.Exists. Is thr any other way to find out. Actually if we rightclick a file or folder and select properties... it will tell us whether it is a file or folder(Type: FileFOlder or File) any ways to retrive tht information. I am using C# application.

    M S 2 Replies Last reply
    0
    • C chandler83

      how to identify whether a dropped object in my application is a file or a folder. atpresent, i am using File.Exists method and Directory.Exists. Is thr any other way to find out. Actually if we rightclick a file or folder and select properties... it will tell us whether it is a file or folder(Type: FileFOlder or File) any ways to retrive tht information. I am using C# application.

      M Offline
      M Offline
      mikone
      wrote on last edited by
      #2

      this depends on the input you get. where do you retrieve the file/folder list from and how does it structure look like? If you can not make a difference between files and folders in the input you will have to do it as you currently do. So please tell me how your input (of files/folders) looks like.

      1 Reply Last reply
      0
      • C chandler83

        how to identify whether a dropped object in my application is a file or a folder. atpresent, i am using File.Exists method and Directory.Exists. Is thr any other way to find out. Actually if we rightclick a file or folder and select properties... it will tell us whether it is a file or folder(Type: FileFOlder or File) any ways to retrive tht information. I am using C# application.

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        I assume you receive the path of the dropped object. If so you could do the following:

        bool isDirectory = ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory);


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        C 1 Reply Last reply
        0
        • S Stefan Troschuetz

          I assume you receive the path of the dropped object. If so you could do the following:

          bool isDirectory = ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory);


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          C Offline
          C Offline
          chandler83
          wrote on last edited by
          #4

          Thank u both for guiding me.

          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