Created
September 8, 2023 20:47
-
-
Save mcc85s/6ca200a3bbca0ebfd0bede7ae81c9cb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class PercentProgress | |
{ | |
[DateTime] $Start | |
[DateTime] $Now | |
[DateTime] $End | |
[Float] $Percent | |
[TimeSpan] $Elapsed | |
[TimeSpan] $Remain | |
[TimeSpan] $Total | |
PercentProgress([String]$Start) | |
{ | |
$This.Start = [DateTime]$Start | |
} | |
[Object] GetPercent([Float]$Percent) | |
{ | |
$This.Now = [DateTime]::Now | |
$This.Elapsed = [TimeSpan]($This.Now-$This.Start) | |
$This.Percent = $Percent | |
$This.Total = [TimeSpan]::FromSeconds(($This.Elapsed.TotalSeconds/$This.Percent)*100) | |
$This.Remain = $This.Total - $This.Elapsed | |
$This.End = [DateTime]($This.Now + $This.Remain) | |
Return $This | |
} | |
} | |
# Suppose the file is located at "C:\Users\user\Download\download.zip" | |
$File = [System.IO.FileInfo]::new("C:\Users\user\Download\download.zip") | |
$Progress = [PercentProgress]::New($File.CreationTime.ToString("MM/dd/yyyy HH:mm:ss")) | |
$Progress.GetPercent(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment