SetLastAccessTime() public static method

public static SetLastAccessTime ( string path, System lastAccessTime ) : void
path string
lastAccessTime System
return void
 public static void SetLastAccessTime(string path, DateTime lastAccessTime)
 {
     if (_provider == null)
     {
         Directory.SetLastAccessTime(path, lastAccessTime);
     }
     else
     {
         _provider.SetLastAccessTime(path, lastAccessTime);
     }
 }
Beispiel #2
0
    /// <summary>
    ///     Sets the directory's last access time.
    /// </summary>
    /// <param name="path">The path of the directory.</param>
    /// <param name="lastAccessTime">A <see cref="DateTime" /> with the directory attribute to set.</param>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" />
    ///     in Visual Basic).
    /// </exception>
    public void SetLastAccessTime(
        string path,
        DateTime lastAccessTime)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        FSDir.SetLastAccessTime(
            path,
            lastAccessTime);
    }
Beispiel #3
0
    /// <summary>
    ///     Asynchronously sets the directory's last access time.
    /// </summary>
    /// <param name="path">The path of the directory.</param>
    /// <param name="lastAccessTime">A <see cref="DateTime" /> with the directory attribute to set.</param>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <returns>A task.</returns>
    public Task SetLastAccessTimeAsync(
        string path,
        DateTime lastAccessTime,
        CancellationToken cancellationToken = default)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(Work.OnThreadPoolAsync(
                   state => FSDir.SetLastAccessTime(
                       state.Path,
                       state.LastAccessTime),
                   (Path: path, LastAccessTime: lastAccessTime),
                   cancellationToken));
    }
Beispiel #4
0
 public static void TouchFiles(string path, DateTime dt)
 {
     foreach (var s in Tools.GetDirs(path))
     {
         try {
             Directory.SetCreationTime(s, dt);
             Directory.SetLastAccessTime(s, dt);
             Directory.SetLastWriteTime(s, dt);
         } catch (Exception e) {
             Console.WriteLine(e.Message);
         }
         foreach (var f in Tools.GetFiles(s, "*.*", SearchOption.TopDirectoryOnly))
         {
             try {
                 File.SetCreationTime(f, dt);
                 File.SetLastAccessTime(f, dt);
                 File.SetLastWriteTime(f, dt);
             } catch (Exception e) {
                 Console.WriteLine(e.Message);
             }
         }
     }
 }
Beispiel #5
0
 public static void SetLastAccessTime(string path, System.DateTime lastAccessTime) =>
 MSIOD.SetLastAccessTime(path, lastAccessTime);
Beispiel #6
0
 public override void SetLastAccessTime(string path, DateTime lastAccessTime)
 {
     Directory.SetLastAccessTime(path, lastAccessTime);
 }