Created
April 2, 2019 07:15
-
-
Save rena2019/2cffdfd7bf527bd1773ebc8455cdfd21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display File Version Info | |
// compile with C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe <filename> | |
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Reflection;//Assembly | |
namespace MyFileInfo | |
{ | |
class FileInfo | |
{ | |
static void Main(String[] args) | |
{ | |
String[] files; | |
if (args.Length > 0) { | |
files = Directory.GetFiles(args[0]); | |
} else { | |
files = Directory.GetFiles("."); | |
} | |
foreach(String file in files) { | |
Console.WriteLine(file); | |
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(file); | |
// Print the file name and version number. | |
Console.WriteLine(" File: " + myFileVersionInfo.FileDescription + | |
", Version number: " + myFileVersionInfo.FileVersion + | |
", ProductName: " + myFileVersionInfo.ProductName + | |
", IsDebug: " + myFileVersionInfo.IsDebug); | |
//string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); | |
string assemblyVersion = ""; | |
string fileVersion = ""; | |
string productVersion = ""; | |
try { | |
assemblyVersion = Assembly.LoadFile(file).GetName().Version.ToString(); | |
fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; | |
productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion; | |
}catch(Exception) { } | |
Console.WriteLine(" assemblyVersion: " + assemblyVersion + ", fileVersion: " + fileVersion + ", productVersion: " + productVersion); | |
Console.WriteLine(" Date modified: " + System.IO.File.GetLastWriteTime(file)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment