Search code examples
c#windowsfileversioninfo

Can we specify a file version when creating a file in C#?


I am creating a file using:

File.WriteAllText(FILEPATHNAME, "SOME VALUE");

When creating a file, is it possible to specify a version programmatically? So that if someone were to use FileVersionInfo object they would get the version I specified?


Solution

  • No, there is no way to write file version in that way, nor that I'm aware of, honestly.

    Possible option is:

    Write file version into the file itself within some formatted data.

    The most common approach I see, is writing into the beginning of the file or on the first line of the file. So you can fast access that information and decide either process with reading or not.