- /// <summary>
- /// 获取程序版本信息
- /// </summary>
- /// <param name="FilePath">程序地址,默认值为当前程序地址</param>
- public void ShowVersionInfo(string FilePath = "")
- {
- //获取文件地址
- if (FilePath == "")
- {
- FilePath = Application.ExecutablePath;
- }
- //获取文件版本信息
- System.Diagnostics.FileVersionInfo fvi =
- System.Diagnostics.FileVersionInfo.GetVersionInfo(FilePath);
- MessageBox.Show(
- "版本号:" + fvi.FileVersion + "\\n" +
- "主要版本号:" + fvi.FileMajorPart + "\\n" +
- "次要版本号:" + fvi.FileMinorPart + "\\n" +
- "内部版本号:" + fvi.FileBuildPart + "\\n" +
- "专用部件号:" + fvi.FilePrivatePart,
- "版本信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- //该片段来自于http://www.codesnippet.cn/detail/2412201514295.html
来源: http://www.codesnippet.cn/detail/2412201514295.html