/// <summary>
/// 获取文件的版本号
/// </summary>
/// <param name="filePath">文件的完整路径</param>
/// <returns>文件的版本号</returns>
public string GetFileVersion(string filePath)
{
string FileVersions = "";
try
{
System.Diagnostics.FileVersionInfo file1 = System.Diagnostics.FileVersionInfo.GetVersionInfo(filePath);
FileVersions = file1.FileVersion;
if (FileVersions != "")
{
string[] strVer = FileVersions.Split('.');
if (strVer.Length == 2)
{
FileVersions = strVer[0] + ".00.0000";
}
}
}
catch (Exception)
{
FileVersions = "";
c#中获取文件的版本号
最新推荐文章于 2021-07-21 08:42:41 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)