guoguogis

  :: :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace FileInfo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)//利用这种判断可避免无文件输入时也出现文件名的情况
            {
                textBox1.Text = this.openFileDialog1.FileName;
            }

          
        }

        private void button2_Click(object sender, EventArgs e)
        {
            String FileName = this.textBox1.Text;
            if(FileName.Length<1)
            {
                return;
            }
            String shortName = FileName.Substring(FileName.LastIndexOf("\\")+1);//下标从0开始
            FileVersionInfo FInfo = FileVersionInfo.GetVersionInfo(FileName);//为磁盘上的物理文件提供版本信息
            this.label2.Text ="公司名称:"+ FInfo.CompanyName;//不能+=,要是那样的话,后面的内容就会另起一行显示
            this.label3.Text = "产品名称:" + FInfo.ProductName;
            this.label4.Text = "语言标志:" + FInfo.Language;
            this.label5.Text = "版本号:" + FInfo.ProductVersion;
            this.label6.Text = "版权信息:" + FInfo.LegalCopyright;

           
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.groupBox1.Text="显示本程序信息";
            this.label2.Text = "公司名称:" + Application.CompanyName;
            this.label3.Text = "区域信息:" + Application.CurrentCulture;
            this.label4.Text = "当前语言:" + Application.CurrentInputLanguage;
            this.label5.Text = "产品名称:" + Application.ProductName;
            this.label6.Text = "版本信息:" + Application.ProductVersion;
            this.label1.Text = "程序路径:";
            this.textBox1.Text = Application.ExecutablePath;
        }
    }
}

posted on 2009-08-27 23:33  guoguogis  阅读(617)  评论(0编辑  收藏  举报