zoukankan      html  css  js  c++  java
  • 文件操作

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;

    namespace WindowsFormsApplication67
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }

            private void button1_Click(object sender, EventArgs e)
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK) //判断是否选择了文件
                {
                    textBox1.Text = openFileDialog1.FileName; //显示选择的文件名
                    FileInfo finfo = new FileInfo(textBox1.Text); //创建FileInfo对象
                    string strCTime, strLATime, strLWTime, strName, strFName, strDName, strISRead;
                    long lgLength;
                    strCTime = finfo.CreationTime.ToShortDateString(); //获取文件创建时间
                    strLATime = finfo.LastAccessTime.ToShortDateString(); //获取上次访问该文件的时间
                    strLWTime = finfo.LastWriteTime.ToString(); //获取上次写入文件的时间
                    strName = finfo.Name; //获取文件名称
                    strFName = finfo.FullName; //获取文件的完整目录
                    strDName = finfo.DirectoryName; //获取文件的完整路径
                    strISRead = finfo.IsReadOnly.ToString(); //获取文件是否只读
                    lgLength = finfo.Length; //获取文件长度

                    MessageBox.Show("文件信息: 创建时间:" + strCTime + " 上次访问时间:" + strLATime + " 上次写入时间:" + strLWTime + " 文件名称:" + strName + " 完整目录:" + strFName + " 完整路径:" + strDName + " 是否只读:" + strISRead + " 文件长度:" + lgLength);

                }
            }
        }
    }

  • 相关阅读:
    [转]How can I create a design netlist without including my source design files?
    [转]基于FPGA的以太网开发
    [转]GMII/RGMII/SGMII/TBI/RTBI接口信号及时序介绍
    [原]Altium画PCB时鼠标十字不能对准焊盘中心
    [转]Altera特殊管脚的使用(适用全系列Altera FPGA,MSEL区别除外)-来自altera论坛
    [转]STM32正交编码器驱动电机
    [转]使用D触发器制作正交编码器的鉴相电路
    [转]解决STM32开启定时器时立即进入一次中断程序问题
    [转]ISE iMPACT bit生成mcs
    [转]NiosII处理器软件代码优化方法
  • 原文地址:https://www.cnblogs.com/milantgh/p/3723730.html
Copyright © 2011-2022 走看看