Click here to Skip to main content
15,905,414 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image processing Pin
User 66587-Jun-08 8:12
User 66587-Jun-08 8:12 
QuestionRe: Image processing Pin
Sajjad Izadi7-Jun-08 8:34
Sajjad Izadi7-Jun-08 8:34 
AnswerRe: Image processing Pin
User 66587-Jun-08 8:43
User 66587-Jun-08 8:43 
GeneralRe: Image processing Pin
Sajjad Izadi7-Jun-08 8:54
Sajjad Izadi7-Jun-08 8:54 
Questionwhat is the current screen resolution? Pin
Sajjad Izadi7-Jun-08 5:55
Sajjad Izadi7-Jun-08 5:55 
AnswerRe: what is the current screen resolution? Pin
Christian Graus7-Jun-08 6:21
protectorChristian Graus7-Jun-08 6:21 
GeneralRe: what is the current screen resolution? Pin
Sajjad Izadi7-Jun-08 7:14
Sajjad Izadi7-Jun-08 7:14 
QuestionSpell check word highlighting problem... Pin
sagedread7-Jun-08 5:11
sagedread7-Jun-08 5:11 
AnswerRe: Spell check word highlighting problem... Pin
Christian Graus7-Jun-08 5:41
protectorChristian Graus7-Jun-08 5:41 
GeneralRe: Spell check word highlighting problem... Pin
sagedread7-Jun-08 6:07
sagedread7-Jun-08 6:07 
GeneralRe: Spell check word highlighting problem... Pin
sagedread7-Jun-08 6:57
sagedread7-Jun-08 6:57 
Question[Message Deleted] Pin
Saba027-Jun-08 4:41
Saba027-Jun-08 4:41 
AnswerRe: Getting Parameter from TextBox Pin
teejayem7-Jun-08 4:55
teejayem7-Jun-08 4:55 
AnswerRe: Getting Parameter from TextBox Pin
Christian Graus7-Jun-08 5:43
protectorChristian Graus7-Jun-08 5:43 
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 

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.