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";

  • 相关阅读:
    OpenStack Trail 部署文档(二)基础服务部署
    OpenStack Trail 部署文档(一)环境规划
    OpenStack Trail 部署文档
    配置kubectl在Mac(本地)远程连接Kubernetes集群
    elasticsearch*3 + Es-Head + kibana Docker集群
    Flex 布局教程:语法篇
    PHP 数组 array_merge 和 数组 + 加号操作的区别
    Redis分布式锁
    Mysql中Exists和In的使用
    让PHP7达到最高性能的几个Tips
  • 原文地址:https://www.cnblogs.com/yinchengliang/p/2669923.html
Copyright © 2011-2022 走看看