Thursday

C# example:how to get version/created time of assembly

1, We need function like this :
  public string GetServerInfo(Assembly _assembly)
{
StringBuilder r = new StringBuilder();
try
{
r.AppendLine("Version:" + _assembly.GetName().Version.ToString());
r.Append("Build: " + System.IO.File.GetLastWriteTime(_assembly.Location).ToString("dd/MM/yyyy HH:mm"));
}
catch (Exception ex)
{
Logger.prn(ex);
}
return r.ToString();
}


Then we can call it like this :

Assembly _assembly = Assembly.GetExecutingAssembly();
string info= GetServerInfo(_assembly);

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...