如何在Compact Framework 3.5中确定dll文件的文件版本

Bad*_*mar 3 c# dll compact-framework assemblyfileversion

我想在指定路径时确定'c#'中dll文件的文件版本.假设path ="\ x\y\z.dll".

如何在给出路径时找到z.dll的文件版本?

注意:我使用Compact Framework 3.5 SP1

wes*_*ton 8

// Get the file version for the notepad.
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\Notepad.exe");

// Print the file name and version number.
Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
                  "Version number: " + myFileVersionInfo.FileVersion);
Run Code Online (Sandbox Code Playgroud)

来自:http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.fileversion.aspx

所以对你来说:

FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"\x\y\z.dll");
Run Code Online (Sandbox Code Playgroud)

如果dll是.net或Win32,则此方法有效.只有当dll是.net时,反射方法才有效.