1

Last Edit: A Version number cannot be added to a generic file in Windows.

Versioning in Windows comes from a VERSIONINFO resource attached to a binary executable file such as .EXE or .DLL. This resource cannot be attached to any arbitrary file and it is not part of any Alternate Data Stream.

I had thought that the version info was stored in an Alternate Data Stream, but it is not.

Is there a way to add a program version number to the meta-data for a file in Windows that is not an executable or dll? We have a linux app. that will be stored on a Windows server and copied to Linux computers when the version changes.

Edit: I would like to Add versioning info to the file, which is kept in an Alternate File stream for the file.

I would like to write a version number to the meta data so that it could be read from a program using a method similar to this:

string fullPath = "folder_name" + "\\" + "linux_app_name";
if (File.Exists(fullPath))
{
    FileAttributes fileAttributes = File.GetAttributes(fullPath);
    FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(fullPath);
    // todo: add version info to the file.
    textBox1.AppendText("File name:\t" + Path.GetFileName(verInfo.FileName) + '\n');
    textBox1.AppendText("Version Info:\t");         
    if (verInfo.FileVersion != null)
    {
        textBox1.AppendText(verInfo.FileVersion);
    }
    else
    {
        textBox1.AppendText("No Version info.");
    }
}

Thanks in advance for any replies.

netcat
  • 1,281
  • 1
  • 11
  • 21
  • 1
    Unclear: are you on windows or linux? On Windows there is no such meta-data for files other than executables, as I know. https://learn.microsoft.com/windows/win32/debug/pe-format & https://en.wikipedia.org/wiki/Portable_Executable –  Oct 24 '19 at 16:08
  • The program is a Linux file, its not a PE of any kind. This file is stored in a Windows folder. I want to add a version to the Alternate file stream where versioning info is kept. – netcat Oct 24 '19 at 18:10
  • 1
    So you need to use a database or an associated description file like `[FilenameWithExtension].meta` and handle this behavior. –  Oct 24 '19 at 18:14
  • 1
    Does this help? https://stackoverflow.com/questions/604960/ntfs-alternate-data-streams-net – Klaus Gütter Oct 24 '19 at 18:54
  • Thanks for the replies. I was looking to open the alternate file stream and write in a version number. The link Klaus G. shared shows this method and it works. I will study the structure to add versioning. – netcat Oct 25 '19 at 03:40
  • Thanks for the helpful info Oliver. We will be storing the version number in a separate file. – netcat Nov 01 '19 at 19:14

1 Answers1

2

I'm posting this answer in case someone else is looking for a way to add versioning to an arbitrary file in Windows that's not a Windows program file.

You can't.

Versioning in Windows comes from a VERSIONINFO resource attached to a binary executable file such as .EXE or .DLL. This resource cannot be attached to any arbitrary file and it is not part of any Alternate Data Stream.

netcat
  • 1,281
  • 1
  • 11
  • 21