views:

164

answers:

2

Hi, Is it possible to read the comments on the dll. Comments are listed under Version when one looks at the property of the dll.

I know that i can get the version number but would rather get the comments as it is user friendly.

Assembly.GetName.Version.ToString --will give version number

thanks

A: 

I know the Title, Subject, Keywords, Comments, etc. viewed in the Summary tab when you right-click a file is a feature called "Alternate Data Streams" (ADS) in Windows. ADS is just the Microsoft name for a filesystem fork.

You should be able to p-invoke to access ADS. An example can be found at CodeProject here. Microsoft has some example C code here.

--- EDIT ---

The comments you are seeing can be accessed via FileVersionInfo.Comments. Here's an example of how to get that:

string comments = System.Diagnostics.FileVersionInfo.GetVersionInfo(
    @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll")

The result is "Flavor=Retail", which is exactly what I see in the Comments under the file.

Paul Williams
I m trying to read comments under version > Assembly version,comments,company,file version,internal name...product version.
Anonymous
OK, those Comments are stuff in the DLL's version resources. If you open a DLL in the Visual Studio resource editor, you'll see wha t I mean.For example, open mscorlib.dll in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (or whatever version you like). Expand the DLL name and Version folder. Double-click on version info 1. The version comes up, and the Comments information is under the block header English (United States).
Paul Williams
A: 

Take a look at System.Diagnostics.FileVersionInfo:

FileVersionInfo info = FileVersionInfo.GetVersionInfo(fileName);

Console.WriteLine("{0}, version {1}, comments: {2}", 
                   fileName, info.FileVersion, info.Comments);

This works for all kinds of dlls, not just .NET ones.

Ruben
Yep this works ...thanks a lot!
Anonymous
FYI i did the followinginfo.GetVersionInfo(assembly.Location).Comments
Anonymous