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. how to get the type of the file selected......

how to get the type of the file selected......

Scheduled Pinned Locked Moved C#
jsontutorial
11 Posts 4 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.
  • I Offline
    I Offline
    imsathy
    wrote on last edited by
    #1

    hi .... im workin on a windows app.... i want to list my contents in detail... like i wanna display the name, size, type and last modified ... i've got the rest how to get the type of the file used.... for eg: if a folder is choosed the type for it is file folder i dont want the extension to be displayed as the type i want the real type of the file used.... im tryin with fileinfo object ... am i missing any thing specific.... imsathy

    C M 2 Replies Last reply
    0
    • I imsathy

      hi .... im workin on a windows app.... i want to list my contents in detail... like i wanna display the name, size, type and last modified ... i've got the rest how to get the type of the file used.... for eg: if a folder is choosed the type for it is file folder i dont want the extension to be displayed as the type i want the real type of the file used.... im tryin with fileinfo object ... am i missing any thing specific.... imsathy

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

      If you suspect the extension could be wrong, then you need to parse the file. Which means writing code for every file format you want to support. Christian Graus - Microsoft MVP - C++

      I 1 Reply Last reply
      0
      • C Christian Graus

        If you suspect the extension could be wrong, then you need to parse the file. Which means writing code for every file format you want to support. Christian Graus - Microsoft MVP - C++

        I Offline
        I Offline
        imsathy
        wrote on last edited by
        #3

        can u tell me how to get the file details sathy

        C 1 Reply Last reply
        0
        • I imsathy

          can u tell me how to get the file details sathy

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

          *sigh* Christian Graus - Microsoft MVP - C++

          V 1 Reply Last reply
          0
          • C Christian Graus

            *sigh* Christian Graus - Microsoft MVP - C++

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

            *grin* I try to answer whatever I can, but don't meet with much success as I'm a tyro myself; but I do see most of your replies. I really feel for you when you get such questions. :) Cheers, Vikram.


            "Don't judge me You could be me in another life In another set of circumstances"   - "Tomorrow we'll see", Sting.

            1 Reply Last reply
            0
            • I imsathy

              hi .... im workin on a windows app.... i want to list my contents in detail... like i wanna display the name, size, type and last modified ... i've got the rest how to get the type of the file used.... for eg: if a folder is choosed the type for it is file folder i dont want the extension to be displayed as the type i want the real type of the file used.... im tryin with fileinfo object ... am i missing any thing specific.... imsathy

              M Offline
              M Offline
              mav northwind
              wrote on last edited by
              #6

              Hi! Could it be that your question has been misinterpreted? Do you want to determine the type of file from the contents of the file because you don't trust the extension (like CG suggested) or do you want to display the name for a given extension like Windows Explorer does (for example: extension is ".txt", but explorer shows "text file")? Regards, mav -- Black holes are the places where god divided by 0...

              I 1 Reply Last reply
              0
              • M mav northwind

                Hi! Could it be that your question has been misinterpreted? Do you want to determine the type of file from the contents of the file because you don't trust the extension (like CG suggested) or do you want to display the name for a given extension like Windows Explorer does (for example: extension is ".txt", but explorer shows "text file")? Regards, mav -- Black holes are the places where god divided by 0...

                I Offline
                I Offline
                imsathy
                wrote on last edited by
                #7

                mav.northwind wrote:

                want to display the name for a given extension like Windows Explorer does (for example: extension is ".txt", but explorer shows "text file")?

                this is exactly wat i want!!! sathy

                M 1 Reply Last reply
                0
                • I imsathy

                  mav.northwind wrote:

                  want to display the name for a given extension like Windows Explorer does (for example: extension is ".txt", but explorer shows "text file")?

                  this is exactly wat i want!!! sathy

                  M Offline
                  M Offline
                  mav northwind
                  wrote on last edited by
                  #8

                  That's an information you get (along with the icon associated, btw.) from a call to SHGetFileInfo from shell32.dll. Take a look at this article[^], it holds all the information you need. Regards, mav -- Black holes are the places where god divided by 0...

                  I 1 Reply Last reply
                  0
                  • M mav northwind

                    That's an information you get (along with the icon associated, btw.) from a call to SHGetFileInfo from shell32.dll. Take a look at this article[^], it holds all the information you need. Regards, mav -- Black holes are the places where god divided by 0...

                    I Offline
                    I Offline
                    imsathy
                    wrote on last edited by
                    #9

                    mav.northwind wrote:

                    That's an information you get (along with the icon associated, btw.) from a call to SHGetFileInfo from shell32.dll.

                    i dont want icon inforamtion tht i have already done. wat i want is if a "test.doc" file is selected i want the type as Microsoft Word Document the details for this one is in shlwapi.dll but the same is working for me in vb.net but i want it in c# .. its not working sathy

                    M 1 Reply Last reply
                    0
                    • I imsathy

                      mav.northwind wrote:

                      That's an information you get (along with the icon associated, btw.) from a call to SHGetFileInfo from shell32.dll.

                      i dont want icon inforamtion tht i have already done. wat i want is if a "test.doc" file is selected i want the type as Microsoft Word Document the details for this one is in shlwapi.dll but the same is working for me in vb.net but i want it in c# .. its not working sathy

                      M Offline
                      M Offline
                      mav northwind
                      wrote on last edited by
                      #10

                      The information you want is simply the szTypeName member of the SHFILEINFO struct. When you read the documentation for SHGetFileInfo you'll see that you'll have to specify the SHGFI_TYPENAME flag to query this piece of information. It's all in the documentation, you just have to read...:) Regards, mav -- Black holes are the places where god divided by 0...

                      I 1 Reply Last reply
                      0
                      • M mav northwind

                        The information you want is simply the szTypeName member of the SHFILEINFO struct. When you read the documentation for SHGetFileInfo you'll see that you'll have to specify the SHGFI_TYPENAME flag to query this piece of information. It's all in the documentation, you just have to read...:) Regards, mav -- Black holes are the places where god divided by 0...

                        I Offline
                        I Offline
                        imsathy
                        wrote on last edited by
                        #11

                        :doh: thanx a lot for the idea... mate sathy

                        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