zoukankan      html  css  js  c++  java
  • 获取文件创建、修改最后访问时间

    .net 方法

    private String filesize(String filename)
            {
                String _this = "";
                if (!String.IsNullOrEmpty(filename))
                {
                    FileInfo objFI = new FileInfo(filename);
                    _this += "详细路径:" + objFI.FullName;
                    _this += "<br>文件名称:" + objFI.Name;
                    _this += "<br>文件长度:" + objFI.Length.ToString();
                    _this += "字节<br>创建时间" + objFI.CreationTime.ToString();
                    _this += "<br>最后访问时间:" + objFI.LastAccessTime.ToString();
                    _this += "<br>修改时间:" + objFI.LastWriteTime.ToString();
                    _this += "<br>所在目录:" + objFI.DirectoryName;
                    _this += "<br>扩展名:" + objFI.Extension;
                    DateTime s1 = objFI.CreationTime;
                    DateTime s2 = System.DateTime.Now;
                    TimeSpan dt = s2 - s1;
                    _this += "<br>创建时间距离现在分钟数:" + System.Convert.ToInt32(dt.TotalMinutes);
                    _this += "<br>创建时间距离现在的小时个数:" + System.Convert.ToInt32(dt.TotalHours);
                    _this += "<br>创建时间距离现在的天数:" + System.Convert.ToInt32(dt.TotalDays);
                }
                return _this;
            }

    Js方法

    function ShowFileAccessInfo(filespec) {
        var fso, f, s;
        fso = new ActiveXObject("Scripting.FileSystemObject");
       f = fso.GetFile(filespec); // filespec 是指定文件的路径(绝对和或相对的),必选项。
       s = f.Path.toUpperCase() + "<br>"; //文件路径
       s += "建立时间: " + f.DateCreated + " ";
       s += "最后访问时间: " + f.DateLastAccessed + " ";
       s += "最后修改时间: " + f.DateLastModified;
    }

    var filespec = "E:\\1.doc";

  • 相关阅读:
    算法的时间复杂度
    二叉树递归建立和遍历
    数据挖掘之分类算法---knn算法(有matlab例子)
    C链表之创建简单静态链表
    ID3决策树算法原理及C++实现(其中代码转自别人的博客)
    adobe reader安装完成之前被中断,错误代码150210解决方法
    Oracle性能诊断艺术-读书笔记
    先对结果集排序然后做update、delete操作
    索引聚簇因子相关
    直方图及low_value、high_value
  • 原文地址:https://www.cnblogs.com/yinchengliang/p/2669923.html
Copyright © 2011-2022 走看看