C# Program to Get Last Write Time in UTC Format of File or Directory

You are currently viewing C# Program to Get Last Write Time in UTC Format of File or Directory

C# program to get last write time in UTC format of file or directory

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            DateTime dt1;
            DateTime dt2;

            dt1 = File.GetLastWriteTimeUtc("ABC.TXT");
            Console.WriteLine("Last Write Time in UTC of file(ABC.TXT) : " + dt1);

            dt2 = File.GetLastWriteTimeUtc("mydir");
            Console.WriteLine("Last Write Time in UTC of directory(mydir) : " + dt2);
        }
    }
}

output

Last Write Time in UTC of file(ABC.TXT) : 10/31/2017 9:38:13 PM
Last Write Time in UTC of directory(mydir) : 10/31/2017 9:08:23 PM

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply