Im uploading a file via FTP (using FtpWebRequest) in Powershell and I want to show a progress bar. Simple progress would be nice but adding remaining time and/or speed would be awesome.
Here is a sample of the code Im using:
$ftp = [System.Net.FtpWebRequest]::Create("ftp://192.168.1.1/Somefile.exe") $ftp = [System.Net.FtpWebRequest]$ftp $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile $ftp.Credentials = new-object System.Net.NetworkCredential($user,$pass) $ftp.UseBinary = $true $ftp.UsePassive = $true $content = [System.IO.File]::ReadAllBytes($item.FullName) $ftp.ContentLength = $content.Length $rs = $ftp.GetRequestStream() $rs.Write($content, 0, $content.Length) $rs.Close() $rs.Dispose()
The code Works perfectly so I rather not change it for just a progress bar but if it is easy to implement then sure….
submitted by /u/riahc3
[link] [comments]
The post Uploading a file using FtpWebRequest and I want to show a Powershell progress bar appeared first on How to Code .NET.