// 显示文件信息。
private void button1_Click(object sender, System.EventArgs e)
{
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
System.IO.FileInfo file = new System.IO.FileInfo(openFileDialog1.FileName);
listView1.Clear();
listView1.Columns.Add("文件名", 100, HorizontalAlignment.Left);
listView1.Columns.Add("大小", 100, HorizontalAlignment.Left);
listView1.Columns.Add("最后访问时间", 100, HorizontalAlignment.Left);
listView1.Columns.Add("最后修改时间", 100, HorizontalAlignment.Left);
listView1.Columns.Add("路径", 200, HorizontalAlignment.Left);
string[] str =
{
file.Name,
file.Length.ToString(),
file.LastAccessTime.ToString(),
file.LastWriteTime.ToString(),
file.DirectoryName
};
ListViewItem item = new ListViewItem(str);
listView1.Items.Add(item);
}
}