日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > C# >内容正文

C#

例用C# 变更文件夹时间

發(fā)布時間:2023/12/19 C# 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 例用C# 变更文件夹时间 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
想變更文件夾的時間.以前做了一個軟件.是變更文件的時間,應(yīng)用了C# API.這次和上一次相同,用Form來通過外部對時間進行確認(rèn).確認(rèn)后應(yīng)用C#中,System.IO ->Directory->SetCreationTime 來對時間進行變更. 以下是C#應(yīng)用的例子.基本相同.但是,不要忘記小問題,下面的例子的命名空間,和函數(shù)的調(diào)用. C# // This sample shows the differences between dates from methods that use //coordinated universal time (UTC) format and those that do not. using System; using System.IO; namespace IOSamples {public class DirectoryUTCTime{public static void Main(){// Set the directory.string n = @"C:\test\newdir";//Create two variables to use to set the time.DateTime dtime1 = new DateTime(2002, 1, 3);DateTime dtime2 = new DateTime(1999, 1, 1);//Create the directory.try{Directory.CreateDirectory(n);}catch (IOException e){Console.WriteLine(e);}//Set the creation and last access times to a variable DateTime value.Directory.SetCreationTime(n, dtime1);Directory.SetLastAccessTimeUtc(n, dtime1);// Print to console the results.Console.WriteLine("Creation Date: {0}", Directory.GetCreationTime(n));Console.WriteLine("UTC creation Date: {0}", Directory.GetCreationTimeUtc(n));Console.WriteLine("Last write time: {0}", Directory.GetLastWriteTime(n));Console.WriteLine("UTC last write time: {0}", Directory.GetLastWriteTimeUtc(n));Console.WriteLine("Last access time: {0}", Directory.GetLastAccessTime(n));Console.WriteLine("UTC last access time: {0}", Directory.GetLastAccessTimeUtc(n));//Set the last write time to a different value.Directory.SetLastWriteTimeUtc(n, dtime2);Console.WriteLine("Changed last write time: {0}", Directory.GetLastWriteTimeUtc(n));}} } // Obviously, since this sample deals with dates and times, the output will vary // depending on when you run the executable. Here is one example of the output: //Creation Date: 1/3/2002 12:00:00 AM //UTC creation Date: 1/3/2002 8:00:00 AM //Last write time: 12/31/1998 4:00:00 PM //UTC last write time: 1/1/1999 12:00:00 AM //Last access time: 1/2/2002 4:00:00 PM //UTC last access time: 1/3/2002 12:00:00 AM //Changed last write time: 1/1/1999 12:00:00 AM

總結(jié)

以上是生活随笔為你收集整理的例用C# 变更文件夹时间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。