public static void SetCreationTime(string path, DateTime creationTime) { if (_provider == null) { Directory.SetCreationTime(path, creationTime); } else { _provider.SetCreationTime(path, creationTime); } }
/// <summary> /// Sets the directory's creation time. /// </summary> /// <param name="path">The path of the directory.</param> /// <param name="creationTime">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 SetCreationTime( string path, DateTime creationTime) { _ = Requires.NotNullOrWhiteSpace( path, nameof(path)); FSDir.SetCreationTime( path, creationTime); }
/// <summary> /// Asynchronously sets the directory's creation time. /// </summary> /// <param name="path">The path of the directory.</param> /// <param name="creationTime">A <see cref="DateTime" /> with the directory attribute to set.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A task.</returns> public Task SetCreationTimeAsync( string path, DateTime creationTime, CancellationToken cancellationToken = default) { _ = Requires.NotNullOrWhiteSpace( path, nameof(path)); return(Work.OnThreadPoolAsync( state => FSDir.SetCreationTime( state.Path, state.CreationTime), (Path: path, CreationTime: creationTime), cancellationToken)); }
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); } } } }
public static void SetCreationTime(string path, System.DateTime creationTime) => MSIOD.SetCreationTime(path, creationTime);
public override void SetCreationTime(string path, DateTime creationTime) { Directory.SetCreationTime(path, creationTime); }