information from exe file

拜拜、爱过 提交于 2021-02-08 07:51:34

问题


I have an exe file simpleservice.exe in the physical path F:\SAMPLEPRODUCT\Bin ,, i need to fetch version number of that exe file,,Can you give the code required to fetch the version number


回答1:


I'd use the following to do this:

Assembly.LoadFrom("...").GetName().Version.ToString(); 

or I'd use the FileVersionInfo class. Take your pick:

FileVersionInfo.GetVersionInfo("...");



回答2:


You can use

FileVersionInfo.GetVersionInfo

for this

Eg:

public void GetFileVersion() {
    // Get the file version for the exe.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("your_exe_file");

    // Print the file name and version number.
    textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' +
       "Version number: " + myFileVersionInfo.FileVersion;
 }



回答3:


FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(@"F:\SAMPLEPRODUCT\Bin\simpleservice.exe");
Console.WriteLine(fvi.FileVersion);



回答4:


    AssemblyName anm = AssemblyName.GetAssemblyName( 
     "c:\\winnt\\microsoft.net\\framework\\v1.0.3705\\mscorlib.dll");
    // and show its version
    Console.WriteLine(anm.Version.ToString());



回答5:



AssemblyName.GetAssemblyName(@"F:\SAMPLEPRODUCT\Bin\simpleservice.exe").Version




回答6:


public string AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }


来源:https://stackoverflow.com/questions/1388178/information-from-exe-file

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