FileVersionInfo.FileVersion returns ProductVersion?

后端 未结 2 2083
名媛妹妹
名媛妹妹 2020-12-22 07:01

I am trying to get the file version using C#:

string file = @\"C:\\somefile.dll\";
Console.WriteLine(FileVersionInfo.GetVersionInfo(file).FileVersion);
         


        
2条回答
  •  太阳男子
    2020-12-22 07:35

    It seems Windows Explorer are stripping leading 0s of the version parts.

    Try creating an assembly with FileVersion 001.001.001.001, it will show as 1.1.1.1 in explorer. But your code would return the actual value (001.001.001.001).

    EDIT:

    Explorer will return 001.001.001.001 as ProductVersion, but only if AssemblyInformationalVersion isn't set, in which case it would return that as ProductVersion.

提交回复
热议问题