.NET Write a file with File Version Information attached

百般思念 提交于 2020-01-14 19:19:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!