.net core 使用远程地址获取文件流
/// <summary>
/// 用远程地址获取文件流
/// </summary>
/// <param name="path">URL</param>
/// <returns></returns>
private byte[] GetUrlMemoryStream(string path)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
List<byte> btlst = new List<byte>();
int b = responseStream.ReadByte();
while (b > -1)
{
btlst.Add((byte)b);
b = responseStream.ReadByte();
}
byte[] bts = btlst.ToArray();
return bts;
}