Record: My first Windows form -- about file attributes

Source: Internet
Author: User

After learning the console application, we started designing the WinForm.

A form in WinForm is actually a class.

Partial-Keyword: partial classification, allowing us to put a class in multiple files

Application. Run () in the program class is the form object to be started when an Application is running.

Let's look at several specific controls:

Button: button. Its name starts with btn.

TextBox: text box, whose name starts with txt

......

In this learning process, we need to deepen our understanding of the attributes and methods of these controls. By learning the usage of a few controls, we need to find rules in them and learn other controls.

In the first form, we want to display the attributes of the file. First, we need to design the style of the display attribute form, put tags, buttons, text boxes in it, and set the name and surface text, easy to use later. After the design, we will click the Browse button to display the file attributes. For details, see the following form:

650) this. width = 650; "title =" image 2.jpg" alt = "224839846.jpg" src =" http://www.bkjia.com/uploads/allimg/131228/19395043T-0.jpg "/>

After the form is designed, we can start to write code. Here, the Click Event of the button is mainly applied.

Private void btnBrowse_Click (object sender, EventArgs e) {// create an OpenFileDialog Class object OpenFileDialog ofd = new OpenFileDialog (); // run the General dialog box ofd. showDialog (); // set the path to the file name string path = ofd. fileName; // put the token in the authorization box this.txt Box1.Text = path; // create a FileInfo Class Object and pass the path to FileInfo fi = new FileInfo (path); // assign this. lbl6.Text = fi. extension. toString (); this. lbl7.Text = fi. fullName; this. lbl8.Text = fi. length. toString (); this. lbl9.Text = fi. length. toString (); this. lbl10.Text = fi. creationTime. toString (); this. lbl11.Text = fi. lastWriteTime. toString (); this. lbl12.Text = fi. lastAccessTime. toString ();}

After that, you can click the Browse button to view the attributes of a specific file.

This article from the "Lanting drunk beauty" blog, please be sure to keep this source http://7607889.blog.51cto.com/7597889/1299598

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.