I have this to make file in current directory:
% { (New-Object System.Net.WebClient).DownloadData($_) | Set-Content -Path $_ -Encoding Byte };
...and I was trying some like:
% { (New-Object System.Net.WebClient).DownloadData($_) | Set-Content -Path ..\qq\$_ -Encoding Byte };
So... it doesn't work for some reason, I know something was missing; but totally forgot how to do it D;
[EDIT] I can do instead Set-Content
something like New-Item
and resolve the "path" problem but it doesnt accept -Encoding Byte
and the final files will be broke.
Based on the MSDN docu :
Set-Content -Path .\DateTime.txt -Value (Get-Date)
Below example downloads a 1MB big test file and stores the content to a temporary file:
$tempFile = New-TemporaryFile
Set-Content -Value (New-Object System.Net.WebClient).DownloadData("http://ovh.net/files/1Mb.dat") -Path $tempFile -Encoding Byte
Get-Content $tempFile
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.