Asp.net C # obtain information about a program file,

Source: Internet
Author: User

Asp.net C # obtain information about a program file,

The Code is as follows:
Using System. Reflection;
Using System. Runtime. CompilerServices;

//
// The general information about the Assembly is as follows:
// Attribute set control. Changing these property values can be modified with the Assembly
// Associated information.
//
[Assembly: AssemblyTitle ("")]
[Assembly: AssemblyDescription ("")]
[Assembly: AssemblyConfiguration ("")]
[Assembly: AssemblyCompany ("")]
[Assembly: AssemblyProduct ("")]
[Assembly: AssemblyCopyright ("")]
[Assembly: AssemblyTrademark ("")]
[Assembly: AssemblyCulture ("")]

//
// The Assembly version information consists of the following four values:
//
// Main version
// Version
// Internal version number
// Revision No.
//
// You can specify all these values, or use the default values of the revision number and internal version number by pressing
// Use '*' as follows '*':

[Assembly: AssemblyVersion ("1. 0. *")]

//
// To sign the assembly, you must specify the key to use. For more information about Assembly signature, see
// Microsoft. NET Framework documentation.
//
// Use the following attributes to control the signature key.
//
// Note:
// (*) If no key is specified, the Assembly will not be signed.
// (*) KeyName indicates that it has been installed on a computer
// Key in the encryption service provider (CSP. KeyFile refers to include
// Key file.
// (*) If both the KeyFile and KeyName values are specified
// Handle the following:
// (1) if the KeyName can be found in CSP, use this key.
// (2) if the KeyName does not exist and the KeyFile exists
// Install the key in the KeyFile into the CSP and use the key.
// (*) To create a KeyFile, you can use the sn.exe (strong name) utility.
// When KeyFile is specified, the location of the KeyFile should be relative
// Project output directory, that is
// % Project Directory % obj <configuration>. For example, if the KeyFile is
// For the project directory, set AssemblyKeyFile
// Specify the attribute as [assembly: AssemblyKeyFile ("... \ mykey. snk")]
// (*) "Delayed signature" is an advanced option-For more information, see Microsoft. NET Framework
// Document.
//
[Assembly: AssemblyDelaySign (false)]
[Assembly: AssemblyKeyFile ("")]
[Assembly: AssemblyKeyName ("")]

Forms1.frm file: core program

The Code is as follows:
Using System;
Using System. Drawing;
Using System. Collections;
Using System. ComponentModel;
Using System. Windows. Forms;
Using System. Data;
Using System. IO;
Using System. Diagnostics;
// Download by http://www.111cn.net
Namespace MyFile
{
/// <Summary>
/// Summary of Form1.
/// </Summary>
Public class Form1: System. Windows. Forms. Form
{
Private System. Windows. Forms. Button button1;
Private System. Windows. Forms. TextBox textBox1;
Private System. Windows. Forms. GroupBox groupBox1;
Private System. Windows. Forms. OpenFileDialog openFileDialog1;
Private System. Windows. Forms. Button button2;
Private System. Windows. Forms. Label label1;
Private System. Windows. Forms. Label label2;
Private System. Windows. Forms. Label label3;
Private System. Windows. Forms. Label label4;
Private System. Windows. Forms. Label label5;
Private System. Windows. Forms. Label label6;
Private System. Windows. Forms. Button button3;
/// <Summary>
/// Required designer variables.
/// </Summary>
Private System. ComponentModel. Container components = null;

Public Form1 ()
{
//
// Required for Windows Form Designer support
//
InitializeComponent ();

//
// TODO: add Any constructor code after InitializeComponent calls
//
}

/// <Summary>
/// Clear all resources in use.
/// </Summary>
Protected override void Dispose (bool disposing)
{
If (disposing)
{
If (components! = Null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing );
}

# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. button1 = new System. Windows. Forms. Button ();
This. textBox1 = new System. Windows. Forms. TextBox ();
This. groupBox1 = new System. Windows. Forms. GroupBox ();
This. openFileDialog1 = new System. Windows. Forms. OpenFileDialog ();
This. button2 = new System. Windows. Forms. Button ();
This. label1 = new System. Windows. Forms. Label ();
This. label2 = new System. Windows. Forms. Label ();
This. label3 = new System. Windows. Forms. Label ();
This. label4 = new System. Windows. Forms. Label ();
This. label5 = new System. Windows. Forms. Label ();
This. label6 = new System. Windows. Forms. Label ();
This. button3 = new System. Windows. Forms. Button ();
This. groupBox1.SuspendLayout ();
This. SuspendLayout ();
//
// Button1
//
This. button1.Location = new System. Drawing. Point (8,192 );
This. button1.Name = "button1 ";
This. button1.Size = new System. Drawing. Size (112, 23 );
This. button1.TabIndex = 1;
This. button1.Text = "browsing Program Files ";
This. button1.Click + = new System. EventHandler (this. button#click );
//
// TextBox1
//
This. textBox1.BackColor = System. Drawing. SystemColors. Control;
This. textBox1.Location = new System. Drawing. Point (104, 8 );
This. textBox1.Name = "textBox1 ";
This. textBox1.ReadOnly = true;
This. textBox1.Size = new System. Drawing. Size (256, 21 );
This. textBox1.TabIndex = 2;
This. textBox1.Text = "";
//
// GroupBox1
//
This. groupBox1.Controls. Add (this. label5 );
This. groupBox1.Controls. Add (this. label4 );
Thi (www.111cn.net) s. groupBox1.Controls. Add (this. label3 );
This. groupBox1.Controls. Add (this. label2 );
This. groupBox1.Controls. Add (this. label1 );
This. groupBox1.Location = new System. Drawing. Point (8, 40 );
This. groupBox1.Name = "groupBox1 ";
This. groupBox1.Size = new System. Drawing. Size (352,144 );
This. groupBox1.TabIndex = 3;
This. groupBox1.TabStop = false;
This. groupBox1.Text = "program file information ";
//
// OpenFileDialog1
//
This. openFileDialog1.Filter = "program file (*. exe) | *. exe | All files (*. *) | *.*";
//
// Button2
//
This. button2.Location = new System. Drawing. Point (120,192 );
This. button2.Name = "button2 ";
This. button2.Size = new System. Drawing. Size (112, 23 );
This. button2.TabIndex = 11;
This. button2.Text = "getting program file information ";
This. button2.Click + = new System. EventHandler (this. button2_Click );
//
// Label1
//
This. label1.Location = new System. Drawing. Point (16, 24 );
This. label1.Name = "label1 ";
This. label1.Size = new System. Drawing. Size (320, 16 );
This. label1.TabIndex = 0;
This. label1.Text = "company name :";
//
// Label2
//
This. label2.Location = new System. Drawing. Point (16, 48 );
This. label2.Name = "label2 ";
This. label2.Size = new System. Drawing. Size (320, 16 );
This. label2.TabIndex = 1;
This. label2.Text = "Product Name :";
//
// Label3
//
This. label3.Location = new System. Drawing. Point (16, 72 );
This. label3.Name = "label3 ";
This. label3.Size = new System. Drawing. Size (320, 16 );
This. label3.TabIndex = 2;
This. label3.Text = "language MARK :";
//
// Label4
//
This. label4.Location = new System. Drawing. Point (16, 96 );
This. label4.Name = "label4 ";
This. label4.Size = new System. Drawing. Size (320, 16 );
This. label4.TabIndex = 3;
This. label4.Text = "version :";
//
// Label5
//
This. label5.Location = new System. Drawing. Point (16,120 );
This. label5.Name = "label5 ";
This. label5.Size = new System. Drawing. Size (320, 16 );
This. label5.TabIndex = 4;
This. label5.Text = "Copyright :";
//
// Label6
//
This. label6.Location = new System. Drawing. Point (8, 16 );
This. label6.Name = "label6 ";
This. label6.Size = new System. Drawing. Size (96, 16 );
This. label6.TabIndex = 12;
This. label6.Text = "program file name :";
//
// Button3
//
This. button3.Location = new System. Drawing. Point (232,192 );
This. button3.Name = "button3 ";
This. button3.Size = new System. Drawing. Size (128, 23 );
This. button3.TabIndex = 13;
This. button3.Text = "getting the program file information ";
This. button3.Click + = new System. EventHandler (this. button3_Click );
//
// Form1
//
This. AutoScaleBaseSize = new System. Drawing. Size (6, 14 );
This. ClientSize = new System. Drawing. Size (368,222 );
This. Controls. Add (this. button3 );
This. Controls. Add (this. label6 );
This. Controls. Add (this. groupBox1 );
This. Controls. Add (this. textBox1 );
This. Controls. Add (this. button1 );
This. Controls. Add (this. button2 );
This. MaximizeBox = false;
This. Name = "Form1 ";
This. StartPosition = System. Windows. Forms. FormStartPosition. CenterScreen;
This. Text = "demonstrate obtaining program file information ";
This. groupBox1.ResumeLayout (false );
This. ResumeLayout (false );

}
# Endregion

/// <Summary>
/// Main entry point of the application.
/// </Summary>
[STAThread]
Static void Main ()
{
Application. Run (new Form1 ());
}

Private void button#click (object sender, System. EventArgs e)
{// Browse Program Files
If (this. openFileDialog1.ShowDialog () = DialogResult. OK)
{
This. textBox1.Text = this. openFileDialog1.FileName;
}
}

Private void button2_Click (object sender, System. EventArgs e)
{// Obtain program file information
String MyFileName = this. textBox1.Text;
If (MyFileName. Length <1)
Return;
String ShortName = MyFileName. Substring (MyFileName. LastIndexOf ("\") + 1 );
This. groupBox1.Text = ShortName + "program file information ";
FileVersionInfo MyInfo = FileVersionInfo. GetVersionInfo (MyFileName );
This. label1.Text = "company name:" + MyInfo. CompanyName;
This. label2.Text = "Product Name:" + MyInfo. ProductName;
This. label3.Text = "Language flag:" + MyInfo. Language;
This. label4.Text = "version:" + MyInfo. FileVersion;
This. label5.Text = "Copyright:" + MyInfo. LegalCopyright;
}

Private void button3_Click (object sender, System. EventArgs e)
{// Obtain information about the current program file
This. groupBox1.Text = "show the program file information ";
This. label1.Text = "company name:" + Application. CompanyName;
This. label2.Text = "region information:" + Application. CurrentCulture;
This. label3.Text = "language flag:" + Application. CurrentInputLanguage;
This. label4.Text = "Product Name:" + Application. ProductName;
This. label5.Text = "Product Version:" + Application. ProductVersion;
}
}
}

This site Original article reprint must indicate the source http://www.111cn.net/net/net.html otherwise please do not reprint


ASPNET c/s B/s is different (do not reprint it if you understand it)

ASP. NET is a B/S program. The so-called B/S is a "Browser/Server" program, because the asp.net code is compiled on the server end and sent to the browser based on browser requests.
C/S refers to the customer/server. Here, clients written by other programs are generally called clients, such as QQ and some trojan programs.

Is ASPNET in the C/S architecture?

ASP. NET developed B/S
C # winfrom is C/S

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.