获取文件的详细属性,大小,修改日期,所在位置等

asp.net 获得文件属性中的修改时间,获得系统文件属性的方法,最后一次写入时间

 1         #region 获取文件的详细属性,大小,修改日期,所在位置等
 2         /// <summary>
 3         /// 获取文件的详细属性,大小,修改日期,所在位置等
 4         /// </summary>
 5         /// <param name="files">文件的路径</param>
 6         /// <returns></returns>
 7         public string GetFileInfo(string files)
 8         {
 9             string result = "";
10             if (!string.IsNullOrEmpty(files))
11             {
12                 string path = Server.MapPath(files);
13                 if (!System.IO.Directory.Exists(path))
14                 {
15                     System.IO.FileInfo fileInfo = new System.IO.FileInfo(path);
16                     result += "详细路径:" + fileInfo.FullName
17                         + "<br>文件名称:" + fileInfo.Name
18                         + "<br>文件长度:" + fileInfo.Length.ToString()
19                         + "字节<br>创建时间" + fileInfo.CreationTime.ToString()
20                         + "<br>最后访问时间:" + fileInfo.LastAccessTime.ToString()
21                         + "<br>修改时间:" + fileInfo.LastWriteTime.ToString()
22                         + "<br>所在目录:" + fileInfo.DirectoryName
23                         + "<br>扩展名:" + fileInfo.Extension;
24                 }
25             }
26             return result;
27         }
28         #endregion
时间: 2024-08-03 21:59:38

获取文件的详细属性,大小,修改日期,所在位置等的相关文章

背水一战 Windows 10 (86) - 文件系统: 获取文件夹的属性, 获取文件夹的缩略图

原文:背水一战 Windows 10 (86) - 文件系统: 获取文件夹的属性, 获取文件夹的缩略图 [源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 获取文件夹的属性 获取文件夹的缩略图 示例1.演示如何获取文件夹的属性FileSystem/FolderProperties.xaml <Page x:Class="Windows10.FileSystem.FolderProperties" xmlns="http://schema

Python 获取文件的创建时间,修改时间和访问时间

# 用到的知识# os.path.getatime(file) 输出文件访问时间# os.path.getctime(file) 输出文件的创建时间# os.path.getmtime(file) 输出文件最近修改时间 #-*- encoding=utf8 -*-import time import os def fileTime(file): return [ time.ctime(os.path.getatime(file)), time.ctime(os.path.getctime(fil

【转】linux C++ 获取文件信息 stat函数详解

stat函数讲解 表头文件:    #include <sys/stat.h>             #include <unistd.h>定义函数:    int stat(const char *file_name, struct stat *buf);函数说明:    通过文件名filename获取文件信息,并保存在buf所指的结构体stat中返回值:      执行成功则返回0,失败返回-1,错误代码存于errno 错误代码:    ENOENT         参数fi

linux文件时间的查看和修改touch

1. linux文件的时间 linux下文件时间主要有下面三种: 1.1 modification time(mtime) 文件修改时间,即文件内容的修改时,更新这个时间,不包括文件权限和属性的修改. 使用ls -l查看,默认显示时间为mtime $ ls -l uconv.h -rw-rw-r-- 1 work work 1808 Jul 23 2013 uconv.h 1.2 status time(ctime) 文件状态status的修改时间,如文件的权限和属性修改时更新这个时间. 使用

文件的SELinux属性

1.临时修改文件的类型属性 文件的类型属性不正确是常见的SELinux拒绝访问的主要原因 1)修改文件的SELinux属性: [[email protected] ~]# touch test.file   ##新建文件 [[email protected] ~]# ls -Z test.file   ##查看文件的SELinux属性 -rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test.file [[email pro

背水一战 Windows 10 (87) - 文件系统: 获取文件的属性, 修改文件的属性, 获取文件的缩略图

[源码下载] 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 获取文件的属性 修改文件的属性 获取文件的缩略图 示例1.演示如何获取文件的属性,修改文件的属性FileSystem/FileProperties.xaml <Page x:Class="Windows10.FileSystem.FileProperties" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentatio

JavaSE8基础 File lastModified 获取文件夹的修改日期

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0) information: 通过这张截图可以看到 测试文件夹 的修改日期. code: package jizuiku0; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; /* * @version V17.09 */ pu

如何在windows下和linux下获取文件(如exe文件)的详细信息和属性

程序员都很懒,你懂的! 最近在项目开发中,由cs开发的exe的程序,需要自动升级,该exe程序放在linux下,自动升级时检测不到该exe程序的版本号信息,但是我们客户端的exe程序需要获取服务器上新程序的版本号信息.最后由我用java实现linux上exe文件的版本号读取功能.下面是详细代码: package com.herman.utils; import java.io.File; import java.io.FileNotFoundException; import java.io.I

python脚本获取文件的创建于修改日期并计算时间差

由于在计算一个算法的运行时间的时候,需要将文件的创建日期与修改日期读取到,然后计算两者之差,在网上搜索了相关的程序之后,自己又修改了一下,把代码贴在这里,供以后查阅使用,也希望可以帮到其他人. 1 # -*- coding: utf-8 -*- 2 """ 3 Created on Mon Dec 12 14:59:46 2016 4 5 @author: shenruixue 6 7 to calculate size after filter in conv and po