标签:style blog color io os sp div on log
1 //get assembly version and create date 2 lblDisplayPCLVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); 3 lblDisplayPCLBuildDate.Text = GetExeBulidDate().ToShortDateString(); 4 5 6 private DateTime GetExeBulidDate() 7 { 8 //get executeing exe location 9 string exeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location; 10 int peHeaderOffset = 60; 11 int linkerTimestampOffset = 8; 12 byte[] bytes = new byte[2048]; 13 Stream s = null; 14 try 15 { 16 s = new FileStream(exeFilePath, FileMode.Open, FileAccess.Read); 17 s.Read(bytes, 0, 2048); 18 } 19 catch (Exception ex) 20 { 21 22 } 23 finally 24 { 25 if (s != null) 26 { 27 s.Close(); 28 } 29 } 30 31 int i = BitConverter.ToInt32(bytes, peHeaderOffset); 32 int secondsSince1970 = BitConverter.ToInt32(bytes, i + linkerTimestampOffset); 33 DateTime retDT = new DateTime(1970, 1, 1, 0, 0, 0); 34 retDT = retDT.AddSeconds(secondsSince1970); 35 retDT = retDT.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(retDT).Hours); 36 37 return retDT; 38 }
Get assembly version and build date
标签:style blog color io os sp div on log
原文地址:http://www.cnblogs.com/JustYong/p/4045802.html