Get and Set File Creation Time Using VB.NET

In this article I describe how to get and set the creation time of file in VB.Net.
  • 4601

Get and Set File Creation Time

The SetCreationTime and GetCreationTime methods are used to set and get the creation date and time of the specified file. The following code snippet sets and gets the creation time of a file.

Imports System.IO

Module Module1

    Sub Main()

       ' Get and set file creation time

        Dim fileName As String = "c:\Temp\Mahesh.txt"

        File.SetCreationTime(fileName, DateTime.Now)

        Dim dt As DateTime = File.GetCreationTime(fileName)

        Console.WriteLine("File created time: {0}", dt.ToString())

        Console.ReadLine()

    End Sub

End Module

Output:

File creation time.jpg

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.