C#获取文件创建时间的方法
本文实例讲述了C#获取文件创建时间的方法。分享给大家供大家参考。具体如下:
C#获取文件创建时间,主要用到了FileInfo的CreattionTime属性
using System;
using System.IO;
class Class1 {
static void Main(string[] args) {
string[] cla = Environment.GetCommandLineArgs();
if (cla.GetUpperBound(0) == 2) {
FileInfo fi = new FileInfo(cla[1]);
fi.MoveTo(cla[2]);
Console.WriteLine("File Created:" + fi.CreationTime.ToString());
Console.WriteLine("Moved to : " + cla[2]);
} else
Console.WriteLine("Usage: mv <source file> <destination file>");
}
}
希望本文所述对大家的C#程序设计有所帮助。
相关推荐
-
C#获取两个时间的时间差并去除周末(取工作日)的方法
本文实例讲述了C#获取两个时间的时间差并去除周末的方法.分享给大家供大家参考.具体分析如下: 一般来说取时间差的代码很多,但是能够只取工作日的时间差的代码很少,这段代码就来实现这一功能. protected void Page_Load(object sender, EventArgs e) { DateTime start = Convert.ToDateTime("2012-12-10"); DateTime end= Convert.ToDateTime("2012-1
-
C#实现从网络同步标准北京时间的方法
本文实例讲述了C#实现从网络同步标准北京时间的方法.分享给大家供大家参考.具体分析如下: 这段C#代码可以从http://www.time.ac.cn网站上获取标准的北京时间,只需简单的组合即可让本地服务器实时同步正确的北京时间 #region /// <summary> /// 获取标准北京时间 /// /// </summary> /// /// <returns></returns> /// public static DateTime GetStan
-
C#返回多少分钟之前或多少分钟之后时间的方法
本文实例讲述了C#返回多少分钟之前或多少分钟之后时间的方法.分享给大家供大家参考.具体实现方法如下: /** * 获取给定时间的之前某分钟的时间 * 比如现在是:2012-10-10 10:10:10 * 给定的分钟数:50 * 得到的时间为:2012-10-10 9:20:10 * * @return strLateMinutesTime 时间字符 */ public static String getLateMinutesTime(Date objDate, String strMinute
-
C#获取目录最后访问时间的方法
本文实例讲述了C#获取目录最后访问时间的方法.分享给大家供大家参考.具体如下: using System; using System.IO; class MainClass { static void Main(string[] args) { FileInfo file = new FileInfo("c:\\a.txt"); // Display directory information. DirectoryInfo dir = file.Directory; Console.W
-
C#实现修改系统时间的方法
本文所述C#获取和修改系统时间的实现步骤为:系统的时间从 SystemTime 结构体中取出,并显示在textBox1上,从setDate,setTime控件中获取年,月,日,小时,分钟,秒信息,存入SystemTime结构体中,然后使用SetLocalTime(ref systemTime)设置为用户指定的时间.本代码编译后会有一个易于操作的窗体. 完整功能代码如下: using System; using System.Drawing; using System.Collections; u
-
C#时间戳基本用法实例分析
本文实例讲述了C#时间戳基本用法.分享给大家供大家参考.具体如下: 一.C#如何生成一个时间戳 /// <summary> /// 获取时间戳 /// </summary> /// <returns></returns> public static string GetTimeStamp() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Conve
-
C#留言时间格式化
平台:Vs2012 主要实现例如空间发表说说时间的显示,如:某人在10秒前回复了你这种效果,可用在Web浏览器,窗体,等... namespace test { class Program { static void Main(string[] args) { DateTime now = DateTime.Now; DateTime time = Convert.ToDateTime( "2014-03-17 11:02:00"); TimeSpan ts = now - time;
-
js与C#进行时间戳转换
JS时间戳转成C#里的时间,再把C#里的时间戳转成JS的时间 JS里的时间戳 复制代码 代码如下: var dt = new Date().getTime();//时间戳 C# 时间戳转时间 复制代码 代码如下: DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime( new DateTime(1970, 1, 1)); long lTime = long.Parse(dt + "0000"); //说
-
C#实现判断一个时间点是否位于给定时间区间的方法
本文实例讲述了C#实现判断一个时间点是否位于给定时间区间的方法.分享给大家供大家参考.具体如下: 本文中实现了函数 复制代码 代码如下: static bool isLegalTime(DateTime dt, string time_intervals); 给定一个字符串表示的时间区间time_intervals: 1)每个时间点用六位数字表示:如12点34分56秒为123456 2)每两个时间点构成一个时间区间,中间用字符'-'连接 3)可以有多个时间区间,不同时间区间间用字符';'隔开 例
-
C#实现两个时间相减的方法
本文实例讲述了C#实现两个时间相减的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test { class Program { static void Main(string[] args) {
随机推荐
- JavaScript实现音乐自动切换和轮播
- AngularJS控制器之间的数据共享及通信详解
- 多种语言下获取当前页完整URL及其参数
- js+html5实现可在手机上玩的拼图游戏
- ajax+php 谷歌搜索框自动填充功能 实例代码
- 用Python登录Gmail并发送Gmail邮件的教程
- 在JS数组特定索引处指定位置插入元素的技巧
- html下利用javascript连数据库
- jQuery中deferred对象使用方法详解
- 利用Js+Css实现折纸动态导航效果实例源码
- Linux中僵尸进程和孤儿进程详解
- 全面理解Java类和对象
- JavaScript妙味课堂 物体平滑移动特效
- 原生js实现百叶窗效果及原理介绍
- 金山反病毒20050117_日报
- 验证坐标在某坐标区域内php代码
- Python的类实例属性访问规则探讨
- php模拟用户自动在qq空间发表文章的方法
- Python线程同步的实现代码
- MYSQL定时清除备份数据的具体操作
