Click here to Skip to main content
15,896,118 members
Home / Discussions / C#
   

C#

 
QuestionHow to Auto update PAD file? Pin
Sukhjinder_K7-Jun-08 2:30
Sukhjinder_K7-Jun-08 2:30 
AnswerRe: How to Auto update PAD file? Pin
Sajjad Izadi7-Jun-08 3:14
Sajjad Izadi7-Jun-08 3:14 
GeneralRe: How to Auto update PAD file? Pin
Sukhjinder_K7-Jun-08 4:00
Sukhjinder_K7-Jun-08 4:00 
AnswerRe: How to Auto update PAD file? Pin
Ed.Poore7-Jun-08 8:57
Ed.Poore7-Jun-08 8:57 
GeneralParse and update PAD from exe info Pin
Sukhjinder_K7-Jun-08 23:59
Sukhjinder_K7-Jun-08 23:59 
GeneralRe: Parse and update PAD from exe info Pin
Ed.Poore8-Jun-08 0:21
Ed.Poore8-Jun-08 0:21 
GeneralWill write my own utility Pin
Sukhjinder_K8-Jun-08 0:29
Sukhjinder_K8-Jun-08 0:29 
GeneralRe: Will write my own utility Pin
Ed.Poore8-Jun-08 0:37
Ed.Poore8-Jun-08 0:37 
After a little searching you don't have to, from Jeff's blog entry[^].

I put together the following class:
public class BuildInformation
{
	private static readonly DateTime BuildOrigin = new DateTime(1970, 1, 1, 0, 0, 0);
	private const int peHeaderOffset = 60;
	private const int linkerTimestampOffset = 8;

	private DateTime _BuildDate;
	public DateTime BuildDate
	{
		get { return this._BuildDate; }
		set { this._BuildDate = value; }
	}

	private Version _Version;
	public Version Version
	{
		get { return this._Version; }
		set { this._Version = value; }
	}

	private static DateTime GetBuildDate(string path)
	{
		byte[] b = new byte[2048];
		using (FileStream fs = File.OpenRead(path))
		{
			fs.Read(b, 0, 2048);
			fs.Close();
		}
		int i = BitConverter.ToInt32(b, peHeaderOffset);
		int secondsSince1970 = BitConverter.ToInt32(b, i + linkerTimestampOffset);

		DateTime dt = BuildOrigin.AddSeconds(secondsSince1970);
		dt = dt.AddHours(TimeZone.CurrentTimeZone.GetUtcOffset(dt).Hours);

		return dt;
	}
	public static BuildInformation Read(string path)
	{
		DateTime buildDate = GetBuildDate(path);
		Version version = Assembly.LoadFrom(path).GetName().Version;
		return new BuildInformation(buildDate, version);
	}

	private BuildInformation(DateTime buildDate, Version version)
	{
		this.BuildDate = buildDate;
		this.Version = version;
	}
}


Hope that helps, things could be tidied up a bit for example using an AppDomain to unload the assembly once it's been loaded etc but this should suffice for most cases.


I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder

GeneralThanks Pin
Sukhjinder_K8-Jun-08 0:41
Sukhjinder_K8-Jun-08 0:41 
QuestionHow is it if i want to have my desktop wallpaper as an image? Pin
Sajjad Izadi6-Jun-08 22:31
Sajjad Izadi6-Jun-08 22:31 
AnswerRe: How is it if i want to have my desktop wallpaper as an image? Pin
Anthony Mushrow7-Jun-08 3:23
professionalAnthony Mushrow7-Jun-08 3:23 
GeneralRe: How is it if i want to have my desktop wallpaper as an image? Pin
Sajjad Izadi7-Jun-08 4:14
Sajjad Izadi7-Jun-08 4:14 
QuestionWhy we use the attribute of class or function Pin
wasimsharp6-Jun-08 20:22
wasimsharp6-Jun-08 20:22 
AnswerRe: Why we use the attribute of class or function Pin
DaveyM696-Jun-08 22:06
professionalDaveyM696-Jun-08 22:06 
Questionhow i can handle the close button Of Form Pin
wasimsharp6-Jun-08 20:19
wasimsharp6-Jun-08 20:19 
AnswerRe: how i can handle the close button Of Form Pin
DaveyM696-Jun-08 21:17
professionalDaveyM696-Jun-08 21:17 
GeneralRe: how i can handle the close button Of Form Pin
wasimsharp6-Jun-08 21:30
wasimsharp6-Jun-08 21:30 
GeneralRe: how i can handle the close button Of Form Pin
DaveyM696-Jun-08 22:07
professionalDaveyM696-Jun-08 22:07 
QuestionBest fit algo Pin
deezZ6-Jun-08 19:07
deezZ6-Jun-08 19:07 
AnswerRe: Best fit algo Pin
Guffa7-Jun-08 0:03
Guffa7-Jun-08 0:03 
AnswerRe: Best fit algo Pin
Robert.C.Cartaino7-Jun-08 5:04
Robert.C.Cartaino7-Jun-08 5:04 
QuestionSeeing which thread owns a lock Pin
K.L.K6-Jun-08 18:53
K.L.K6-Jun-08 18:53 
QuestionProcess.Start C# Pin
satsumatable6-Jun-08 11:47
satsumatable6-Jun-08 11:47 
AnswerRe: Process.Start C# Pin
PIEBALDconsult6-Jun-08 13:24
mvePIEBALDconsult6-Jun-08 13:24 
QuestionProcess.Start on Vista return invalid Process Pin
dcabrames6-Jun-08 8:37
dcabrames6-Jun-08 8:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.