我在System.net.HttpWebResponse
中使用此方法。但我无法将所有字节都放入变量中,我该怎么办?
[System.Net.HttpWebRequest] $webRequest = [System.Net.WebRequest]::Create('URl')
$webRequest.Timeout = 300000
$webRequest.Method = 'POST'
$webRequest.ContentType = 'multipart/form-data'
$webRequest.ContentLength = $data.Length;
$requestStream = $webRequest.GetRequestStream()
$requestStream.Write($data, 0, $data.Length)
$requestStream.Flush()
$requestStream.Close()
[System.Net.HttpWebResponse] $webResponse = $webRequest.GetResponse()
$streamReader = New-Object IO.BinaryReader($webResponse.GetResponseStream())
$ByteArr = $streamReader.ReadBytes($streamReader.BaseStream.Length)
为什么$streamReader.BaseStream.length
没有长度?当我使用流泵浦字节中的$streamReader.ReadByte()
方法时。有矛盾吗?