C# code for the properties that can retrieve the version embedded in the executable: http://wp.me/p3Uuaw-Hj
class Program | |
{ | |
private string executableVersion = null; | |
private string ExecutableVersion | |
{ | |
get | |
{ | |
if (executableVersion == null) | |
{ | |
Assembly assembly = Assembly.GetExecutingAssembly(); | |
string assemblyName = assembly.GetName().Name; | |
// "Properties" is required since it is located in the | |
// Properties folder of the project and was thusly embedded | |
// as such. | |
string filepath = assemblyName + @".Properties.executable.version"; | |
string[] names = assembly.GetManifestResourceNames(); | |
var stream = assembly.GetManifestResourceStream(filepath); | |
if (stream == null) | |
{ | |
throw new Exception(String.Format("Could not get resource-stream with name [{0}] for version content from assembly [{1}]. Available: {2}", filepath, assembly.FullName, String.Join(",", names))); | |
} | |
TextReader tr = new StreamReader(stream); | |
executableVersion = tr.ReadToEnd().Trim(); | |
} | |
return executableVersion; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment