SetLastAccessTimeUtc() public static méthode

public static SetLastAccessTimeUtc ( String path, DateTime lastAccessTimeUtc ) : void
path String
lastAccessTimeUtc DateTime
Résultat void
    /// <summary>
    ///     Sets the file's last access time.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="lastAccessTime">A <see cref="DateTime" /> with the file 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));

        FSFile.SetLastAccessTimeUtc(
            path,
            lastAccessTime);
    }
    /// <summary>
    ///     Asynchronously sets the file's last access time.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="lastAccessTime">A <see cref="DateTime" /> with the file attribute to set.</param>
    /// <param name="cancellationToken">The cancellation token to stop this operation.</param>
    /// <returns>A task representing the current operation.</returns>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> is <see langword="null" /> (<see langword="Nothing" /> in Visual Basic).
    /// </exception>
    public Task SetLastAccessTimeAsync(
        string path,
        DateTime lastAccessTime,
        CancellationToken cancellationToken = default)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(Work.OnThreadPoolAsync(
                   state => FSFile.SetLastAccessTimeUtc(
                       state.Path,
                       state.LastAccessTime),
                   (Path: path, LastAccessTime: lastAccessTime),
                   cancellationToken));
    }
Exemple #3
0
        public static Stream OpenWriter(string file)
        {
            bool   exist = Exists(file);
            Stream _IO   = new Stream(new MSIO.FileStream(file, MSIO.FileMode.OpenOrCreate,
                                                          MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite), canRead: false)
            {
                File = file
            };

            System.DateTime t = System.DateTime.UtcNow;
            if (!exist)
            {
                MSIOF.SetCreationTimeUtc(file, t);
            }
            MSIOF.SetLastWriteTimeUtc(file, t);
            MSIOF.SetLastAccessTimeUtc(file, t); return(_IO);
        }
Exemple #4
0
 public static void SetLastAccessTimeUtc(string path, System.DateTime lastAccessTimeUtc) =>
 MSIOF.SetLastAccessTimeUtc(path, lastAccessTimeUtc);
Exemple #5
0
 public void SetLastAccessTime(DateTimeOffset lastAccessTime)
 => F.SetLastAccessTimeUtc(this.FullName, lastAccessTime.UtcDateTime);