Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Auto update PAD file?

How to Auto update PAD file?

Scheduled Pinned Locked Moved C#
announcementquestionhtmltoolsjson
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sukhjinder_K
    wrote on last edited by
    #1

    How can I update the contents of my PAD file automatically. I need to update the following + Program Version from Assembly Version of the main exe + Release Date based on the current system date + Size of the Zip file containing my project exe and data files I understand this would require some parsing of PAD files. What I'm looking for is a tool which can help me do that. If there is none I may write my own utility. Thanks Sukhjinder... Mods, please move this post to the correct forum

    Looking for help on my OpenSource Media Player LetsYo

    S E 2 Replies Last reply
    0
    • S Sukhjinder_K

      How can I update the contents of my PAD file automatically. I need to update the following + Program Version from Assembly Version of the main exe + Release Date based on the current system date + Size of the Zip file containing my project exe and data files I understand this would require some parsing of PAD files. What I'm looking for is a tool which can help me do that. If there is none I may write my own utility. Thanks Sukhjinder... Mods, please move this post to the correct forum

      Looking for help on my OpenSource Media Player LetsYo

      S Offline
      S Offline
      Sajjad Izadi
      wrote on last edited by
      #2

      i think for your first and second question you should expand the 'properties' folder from solution explorer and double click on 'AssemblyInfo.cs'. you can change what you want there.

      S 1 Reply Last reply
      0
      • S Sajjad Izadi

        i think for your first and second question you should expand the 'properties' folder from solution explorer and double click on 'AssemblyInfo.cs'. you can change what you want there.

        S Offline
        S Offline
        Sukhjinder_K
        wrote on last edited by
        #3

        In my program the exe's version number is being auto generated via the statement [assembly: AssemblyVersion("0.8.2.*")] So I'm not concerned about it. What I want is that the latest version number, Release date be auto updated in my PAD file...

        Looking for help on my OpenSource Media Player LetsYo

        1 Reply Last reply
        0
        • S Sukhjinder_K

          How can I update the contents of my PAD file automatically. I need to update the following + Program Version from Assembly Version of the main exe + Release Date based on the current system date + Size of the Zip file containing my project exe and data files I understand this would require some parsing of PAD files. What I'm looking for is a tool which can help me do that. If there is none I may write my own utility. Thanks Sukhjinder... Mods, please move this post to the correct forum

          Looking for help on my OpenSource Media Player LetsYo

          E Offline
          E Offline
          Ed Poore
          wrote on last edited by
          #4

          What are you trying to accomplish exactly? Create a PAD file for your project automatically when you build it? I.e. you click one button it zips it all up, creates the PAD file and zips everything up?


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

          S 1 Reply Last reply
          0
          • E Ed Poore

            What are you trying to accomplish exactly? Create a PAD file for your project automatically when you build it? I.e. you click one button it zips it all up, creates the PAD file and zips everything up?


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

            S Offline
            S Offline
            Sukhjinder_K
            wrote on last edited by
            #5

            I've already created a utility which copies and zips up my project files. What I really need is some tool which can update my PAD file by reading the project exe. Updations to be made in PAD file are 1) Program version read from project exe 2) Release date, current system date The tool just needs to parse the PAD XML data and update it with the latest exe information.

            Looking for help on my OpenSource Media Player LetsYo

            E 1 Reply Last reply
            0
            • S Sukhjinder_K

              I've already created a utility which copies and zips up my project files. What I really need is some tool which can update my PAD file by reading the project exe. Updations to be made in PAD file are 1) Program version read from project exe 2) Release date, current system date The tool just needs to parse the PAD XML data and update it with the latest exe information.

              Looking for help on my OpenSource Media Player LetsYo

              E Offline
              E Offline
              Ed Poore
              wrote on last edited by
              #6
              1. You can get the version from an executable project.exe with this code:

              private static Version GetVersion(string assemblyUri)
              {
              Assembly assembly = Assembly.LoadFile(assemblyUri);
              return assembly.GetName().Version;
              }

              1. This is a little more complicated, you can extract the build date from the assembly provided that you leave the AssemblyVersion in the format x.x.*.* where the *s are replaced by the compiler. There's a discussion about it here[^]. Personally I'd to the last suggestion and create a custom build event to embed it into the assembly, it's the most reliable method.

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

              S 1 Reply Last reply
              0
              • E Ed Poore
                1. You can get the version from an executable project.exe with this code:

                private static Version GetVersion(string assemblyUri)
                {
                Assembly assembly = Assembly.LoadFile(assemblyUri);
                return assembly.GetName().Version;
                }

                1. This is a little more complicated, you can extract the build date from the assembly provided that you leave the AssemblyVersion in the format x.x.*.* where the *s are replaced by the compiler. There's a discussion about it here[^]. Personally I'd to the last suggestion and create a custom build event to embed it into the assembly, it's the most reliable method.

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

                S Offline
                S Offline
                Sukhjinder_K
                wrote on last edited by
                #7

                Thanks for the help. It seems I'll have to write my own utility. Thanks...

                Looking for help on my OpenSource Media Player LetsYo

                E 1 Reply Last reply
                0
                • S Sukhjinder_K

                  Thanks for the help. It seems I'll have to write my own utility. Thanks...

                  Looking for help on my OpenSource Media Player LetsYo

                  E Offline
                  E Offline
                  Ed Poore
                  wrote on last edited by
                  #8

                  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

                  S 1 Reply Last reply
                  0
                  • E Ed Poore

                    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

                    S Offline
                    S Offline
                    Sukhjinder_K
                    wrote on last edited by
                    #9

                    Thanks I'll review it and soon provide a little something which we can use to update our PADs with latest Version and Date.

                    Looking for help on my OpenSource Media Player LetsYo

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups