SetCreationTimeUtc() public static méthode

public static SetCreationTimeUtc ( String path, DateTime creationTimeUtc ) : void
path String
creationTimeUtc DateTime
Résultat void
Exemple #1
0
 public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc)
 {
     if (_provider == null)
     {
         File.SetCreationTimeUtc(path, creationTimeUtc);
     }
     else
     {
         _provider.SetCreationTimeUtc(path, creationTimeUtc);
     }
 }
    /// <summary>
    ///     Sets the file's creation time.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="creationTime">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 SetCreationTime(
        string path,
        DateTime creationTime)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        FSFile.SetCreationTimeUtc(
            path,
            creationTime);
    }
    /// <summary>
    ///     Asynchronously sets the file's creation time.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="creationTime">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 SetCreationTimeAsync(
        string path,
        DateTime creationTime,
        CancellationToken cancellationToken = default)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));

        return(Work.OnThreadPoolAsync(
                   state => FSFile.SetCreationTimeUtc(
                       state.Path,
                       state.CreationTime),
                   (Path: path, CreationTime: creationTime),
                   cancellationToken));
    }
Exemple #4
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 #5
0
 public static void SetCreationTimeUtc(string path, System.DateTime creationTimeUtc) =>
 MSIOF.SetCreationTimeUtc(path, creationTimeUtc);
Exemple #6
0
 public override void SetCreationTimeUtc(string path, DateTime creationTimeUtc)
 {
     File.SetCreationTimeUtc(path, creationTimeUtc);
 }
Exemple #7
0
 public void SetCreationTime(DateTimeOffset creationTime)
 => F.SetCreationTimeUtc(this.FullName, creationTime.UtcDateTime);