C# File SetLastWriteTime

Description

File SetLastWriteTime Sets the date and time that the specified file was last written to.

Syntax

File.SetLastWriteTime has the following syntax.


public static void SetLastWriteTime(
  string path,
  DateTime lastWriteTime
)

Parameters

File.SetLastWriteTime has the following parameters.

  • path - The file for which to set the date and time information.
  • lastWriteTime - A DateTime containing the value to set for the last write date and time of path. This value is expressed in local time.

Returns

File.SetLastWriteTime method returns

Example

The following example demonstrates SetLastWriteTime.


/*from   ww w.  j av  a2  s  . co  m*/

using System;
using System.IO;

class Test 
{
    public static void Main() 
    {
      string path = @"c:\Temp\MyTest.txt";
      File.SetLastWriteTime(path, new DateTime(2014,4,3));
    }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter