问题
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?
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/5290179/net-write-a-file-with-file-version-information-attached