using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;namespace DocumentSearch.Helper{ class FileInfoHelper { /// /// get file path,include file name /// /// DriveName:\path\****.EXE public string GetFilePath() { return this.GetType().Assembly.Location;//当前执行文件 path\name } public List
调用:
private void frmMain_Load(object sender,EventArgs e) { //get file version date List listFileInfo = fileInfoHlp.GetFileInfo(fileInfoHlp.GetFilePath()); if (listFileInfo.Count > 0) { **dynamic fileinfo = listFileInfo[0]; //使用dynamic类 this.Text = $"Main Form 【VerDate:{fileinfo.FileCreateDate}】";** } }