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. Content Type

Content Type

Scheduled Pinned Locked Moved C#
csharphelp
5 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.
  • S Offline
    S Offline
    Stephen Lintott
    wrote on last edited by
    #1

    Is there any way that I can retrieve the content type of a document without going into the regestry. I'm not working with HttpResponse so that's out. I need something like

    FileInfo file =new FileInfo(path);
    file.ContentType

    Only file.ContentType does not exist in dotnet. Please Help

    Stephen Lintott Bsc IT (RAU)

    E 1 Reply Last reply
    0
    • S Stephen Lintott

      Is there any way that I can retrieve the content type of a document without going into the regestry. I'm not working with HttpResponse so that's out. I need something like

      FileInfo file =new FileInfo(path);
      file.ContentType

      Only file.ContentType does not exist in dotnet. Please Help

      Stephen Lintott Bsc IT (RAU)

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      I will assume you are using windows ... so you can usually cheat and use the file extension to determine the appropriate content-type. After that you could examine the file contents for known header information. However, the most accurate would be the Windows API: http://msdn.microsoft.com/en-us/library/ms775107(VS.85).aspx[^]

      Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
      If you don't ask questions the answers won't stand in your way.
      Most of this sig is for Google, not ego.

      S 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        I will assume you are using windows ... so you can usually cheat and use the file extension to determine the appropriate content-type. After that you could examine the file contents for known header information. However, the most accurate would be the Windows API: http://msdn.microsoft.com/en-us/library/ms775107(VS.85).aspx[^]

        Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
        If you don't ask questions the answers won't stand in your way.
        Most of this sig is for Google, not ego.

        S Offline
        S Offline
        Stephen Lintott
        wrote on last edited by
        #3

        My C is not that great. Thanks for the link but can I ask you for an example of how the function is used.

        Stephen Lintott Bsc IT (RAU)

        J 1 Reply Last reply
        0
        • S Stephen Lintott

          My C is not that great. Thanks for the link but can I ask you for an example of how the function is used.

          Stephen Lintott Bsc IT (RAU)

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          pinvoke.net for examples of how to use WinAPI's http://pinvoke.net/default.aspx/urlmon/FindMimeFromData.html[^]

          S 1 Reply Last reply
          0
          • J J4amieC

            pinvoke.net for examples of how to use WinAPI's http://pinvoke.net/default.aspx/urlmon/FindMimeFromData.html[^]

            S Offline
            S Offline
            Stephen Lintott
            wrote on last edited by
            #5

            Tx

            Stephen Lintott Bsc IT (RAU)

            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