Directory.GetCreationTimeUtc Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the creation date and time, in Coordinated Universal Time (UTC) format, of a directory.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function GetCreationTimeUtc (
	path As String
) As Date


Type: System.String

The path of the directory.

Return Value

Type: System.DateTime

A structure that is set to the creation date and time for the specified directory. This value is expressed in UTC time.

Exception Condition

The caller does not have the required permission.


path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the GetInvalidPathChars method.


path is null.


The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.


This method may return an inaccurate value, because it uses native functions whose values may not be continuously updated by the operating system.

If the directory described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

Use this method to get the creation time for a directory based on Coordinated Universal Time (UTC).

The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output.

' This sample shows the differences between dates from methods that use
'coordinated universal time (UTC) format and those that do not.
Imports System
Imports System.IO

Public Class DirectoryUTCTime

   Public Shared Sub Main()
      ' Set the directory.
      Dim n As String = "C:\test\newdir"
      'Create two variables to use to set the time.
      Dim dtime1 As New DateTime(2002, 1, 3)
      Dim dtime2 As New DateTime(1999, 1, 1)

      'Create the directory.
      Catch e As IOException
      End Try

      '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))
   End Sub 'Main
End Class 'DirectoryUTCTime

' 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


for reading the specified file or directory. Associated enumeration: FileIOPermissionAccess.Read

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top