将版本号添加到 Windows 中的通用文件
Add Version number to a generic file in Windows
上次编辑:无法将版本号添加到 Windows 中的通用文件。
Windows 中的版本控制来自附加到二进制可执行文件(例如 .EXE 或 .DLL)的 VERSIONINFO 资源。此资源不能附加到任何任意文件,它不是任何备用数据流的一部分。
我以为版本信息存储在备用数据流中,但事实并非如此。
有没有办法将程序版本号添加到 Windows 中不是可执行文件或 dll 的文件的元数据中?我们有一个 linux 应用程序。将存储在 Windows 服务器上,并在版本更改时复制到 Linux 计算机。
编辑:我想向文件添加版本控制信息,该信息保存在文件的备用文件流中。
我想将版本号写入元数据,以便可以使用与此类似的方法从程序中读取它:
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.");
}
}
提前感谢您的任何回复。
我发布这个答案是为了防止其他人正在寻找一种方法来向 Windows 中的任意文件添加版本控制,该文件不是 Windows 程序文件。
你不能。
Windows 中的版本控制来自附加到二进制可执行文件(例如 .EXE 或 .DLL)的 VERSIONINFO 资源。此资源不能附加到任何任意文件,它不是任何备用数据流的一部分。
上次编辑:无法将版本号添加到 Windows 中的通用文件。
Windows 中的版本控制来自附加到二进制可执行文件(例如 .EXE 或 .DLL)的 VERSIONINFO 资源。此资源不能附加到任何任意文件,它不是任何备用数据流的一部分。
我以为版本信息存储在备用数据流中,但事实并非如此。
有没有办法将程序版本号添加到 Windows 中不是可执行文件或 dll 的文件的元数据中?我们有一个 linux 应用程序。将存储在 Windows 服务器上,并在版本更改时复制到 Linux 计算机。
编辑:我想向文件添加版本控制信息,该信息保存在文件的备用文件流中。
我想将版本号写入元数据,以便可以使用与此类似的方法从程序中读取它:
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.");
}
}
提前感谢您的任何回复。
我发布这个答案是为了防止其他人正在寻找一种方法来向 Windows 中的任意文件添加版本控制,该文件不是 Windows 程序文件。
你不能。
Windows 中的版本控制来自附加到二进制可执行文件(例如 .EXE 或 .DLL)的 VERSIONINFO 资源。此资源不能附加到任何任意文件,它不是任何备用数据流的一部分。