c# - Add Version number to a generic file in Windows
问题描述
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.
解决方案
如果其他人正在寻找一种方法来将版本控制添加到 Windows 中不是 Windows 程序文件的任意文件中,我将发布此答案。
你不能。
Windows 中的版本控制来自附加到二进制可执行文件(如 .EXE 或 .DLL)的 VERSIONINFO 资源。此资源不能附加到任何任意文件,并且它不是任何备用数据流的一部分。
推荐阅读
- python - 如何在 iis 上将 python 代码发布为 web api
- java - golang 中的 java RSA/ECB/OAEPWithSHA 256AndMGF1Padding 等效项
- openedge - HTML 文件内容到正在进行中的电子邮件正文 4gl
- python - 带有 Sphinx 的文档标签版本
- javascript - 迁移到 Dash.js 3.0.0 后,直播延迟了 2 小时
- vue.js - VueJS:为什么当孩子触发自定义事件时,父母的数据属性没有更新?
- python - pandas add column using map based on two variable
- puppet - cwd 在 exec - puppet 5.5.12 中的 onlyif 之前评估
- android - 许多具有相同内容的活动(广告视图,奖励广告视图,功能......)如何避免重复代码?
- pandas - fast_executemany=True throwing DBAPIError: sqlalchemy 1.3.5 版本中的函数序列错误