I am trying to get dll file version on client side only.
Writing code on Angular 16 (2+), any solution on ts/js would work.
I tried using DataView and couple of solutions i found online, though they are returning file version though it is not correct.
onSelectFile(event: any) { const file2: File = event.target.files[0]; this.readFile(file2);}readFile(file: File) { const reader = new FileReader(); reader.readAsArrayBuffer(file); reader.onload = (e: any) => { const arrayBuffer = e.target.result; const version = this.extractVersion(arrayBuffer); console.log('DLL Version:', version); };}extractVersion(arrayBuffer: ArrayBuffer): string { const dataView = new DataView(arrayBuffer); // Get the offset of the version information const versionOffset = dataView.getUint32(60, true); // Read the version information from the specified offset const majorVersion = dataView.getUint16(versionOffset + 8, true); const minorVersion = dataView.getUint16(versionOffset + 10, true); const buildNumber = dataView.getUint16(versionOffset + 12, true); const revisionNumber = dataView.getUint16(versionOffset + 14, true); // Construct the version string const version = `${majorVersion}.${minorVersion}.${buildNumber}.${revisionNumber}`; // Print the version return version;}
Output I am getting for dll Version is: -
DLL Version: 58052.49828.0.0
If I check the properties and go to details tab, version is something else: -
Can I know, how to extract the correct fileversion on client side either using DataView or any other class/library?