• 获取文件创建、修改最后访问时间


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

  • 相关阅读:
    openwrt
    第37章 socket编程 之练习:实现简单的web服务器
    Unix domain socket IPC
    String题目解析1
    this()与super()
    if当中是赋值怎么办
    编译时检查错误有哪些
    int与Integer
    log4j日志级别怎么搞
    数据库标准八步每一步中的作用
  • 原文地址:https://www.cnblogs.com/yinchengliang/p/2669923.html
Copyright © 2020-2023  润新知