John
John

Reputation: 31

.NET Write a file with File Version Information attached

Is there anyway to say... Include a version number when creating a text file?

Basically, my process is writing a text file that I need to check if there's a newer version available. My plan was to use FileVersionInfo to determine the current version and the version on the PC. However, I can't figure out how to write the file to the PC with a version attached to the file.

Any ideas?

Upvotes: 3

Views: 2002

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1062905

Typical options here include;

  • hashing the contents and comparing that
  • relying onthe audit dates
  • storing version in the file and
  • storing version in the first line of the file
  • using file-watcher events (unreliable by itself, by most accounts)
  • using the alternative data streams in NTFS

But no; plain text files don't have much associated metadata by themselves

Upvotes: 4

Jonathan Wood
Jonathan Wood

Reputation: 67223

Plain text files have no embedded resources (except for file attributes such as the file date).

Either write the version as part of the text that can easily be parsed, use the file date to track versions, or use binary files and embed your own resources.

Upvotes: 1

Related Questions