123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsIOFileInfoDemo
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
-
-
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
-
- textBox1.Text = openFileDialog1.FileName;
-
- FileInfo finfo = new FileInfo(textBox1.Text);
-
- string strCTime, strLATime, strLWTime, strName, strFName, strDName, strISRead;
- long lgLength;
-
- strCTime = finfo.CreationTime.ToShortDateString();
-
- strLATime = finfo.LastAccessTime.ToShortDateString();
-
- strLWTime = finfo.LastWriteTime.ToShortDateString();
-
- strName = finfo.Name;
-
- strFName = finfo.FullName;
-
- strDName = finfo.DirectoryName;
-
- strISRead = finfo.IsReadOnly.ToString();
-
- lgLength = finfo.Length;
- MessageBox.Show("文件信息:\n创建时间:" + strCTime + " 上次访问时间:" + strLATime + "\n上次写入时间:" + strLWTime + " 文件名称:" + strName + "\n完整目录:" + strFName + "\n完整路径:" + strDName + "\n是否只读:" + strISRead + " \n文件长度:" + lgLength);
- }
- }
- }
- }
|