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. Get Win32 file version?

Get Win32 file version?

Scheduled Pinned Locked Moved C#
questioncsharpcomannouncement
5 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.
  • F Offline
    F Offline
    flipdoubt
    wrote on last edited by
    #1

    Is there an interop or P/Invoke (or are those the same?) call to ascertain the Win32 file version of a file? I want to list the version of all files in a directory, but some may not be .NET assemblies. How can I read this info? Thanks.

    P L S 3 Replies Last reply
    0
    • F flipdoubt

      Is there an interop or P/Invoke (or are those the same?) call to ascertain the Win32 file version of a file? I want to list the version of all files in a directory, but some may not be .NET assemblies. How can I read this info? Thanks.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Use FileVersionInfo.FileVersion. Try:

      FileVersionInfo fv = FileVersionInfo.GetVersionInfo("Filename");
      Console.WriteLine(fv.FileVersion);
      

      Deja View - the feeling that you've seen this post before.

      F 1 Reply Last reply
      0
      • F flipdoubt

        Is there an interop or P/Invoke (or are those the same?) call to ascertain the Win32 file version of a file? I want to list the version of all files in a directory, but some may not be .NET assemblies. How can I read this info? Thanks.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, have a look at FileVersionInfo.GetVersionInfo(), it works for all kinds of files. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        1 Reply Last reply
        0
        • P Pete OHanlon

          Use FileVersionInfo.FileVersion. Try:

          FileVersionInfo fv = FileVersionInfo.GetVersionInfo("Filename");
          Console.WriteLine(fv.FileVersion);
          

          Deja View - the feeling that you've seen this post before.

          F Offline
          F Offline
          flipdoubt
          wrote on last edited by
          #4

          Thanks, guys! That is quick service.

          1 Reply Last reply
          0
          • F flipdoubt

            Is there an interop or P/Invoke (or are those the same?) call to ascertain the Win32 file version of a file? I want to list the version of all files in a directory, but some may not be .NET assemblies. How can I read this info? Thanks.

            S Offline
            S Offline
            Scott Dorman
            wrote on last edited by
            #5

            As has already been said, using FileVersionInfo.GetVersionInfo() is the right way to go. If you are only looking for the version number data, there aren't any problems. However, if you want to start looking at any of the other properties, a lot of the .NET assemblies will report incorrect data, particularly the IsDebug property.

            ----------------------------- In just two days, tomorrow will be yesterday. http://geekswithblogs.net/sdorman

            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