C#文件基本操作2-获取文件基本信息
2013-06-11 10:15
316 查看
原来的样例是用MESSAGEBOX来输出,我改成用RICHTEXT来输出。好看点哈。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace WindowsFormsApplication1 { 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, lgLength; string strContent; 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.ToString(); strContent = "文件信息:\n创建时间: "+ strCTime + "\n上次访问时间:" + strLATime + "\n上次写入时间:" + strLWTime + "\n文件名称:" + strName + "\n完整目录:" + strFName + "\n完整路径:" + strDName + "\n是否只读:" + strISRead + "\n文件长度:" + lgLength; richTextBox1.Text = strContent; } } } }
相关文章推荐
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- 文件基本操作之获取文件基本信息
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)zz
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- C# 对包含文件或目录路径信息的 System.String 实例执行操作
- C#获取文件相关信息的方法
- Python 获取根据文件URL 获取文件的基本信息
- c# .Net :Excel NPOI导入导出操作教程之读取Excel文件信息及输出
- C# 获取文件信息并导出Excel,Xml报表
- php获取文件类型和文件信息操作
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据