下载远程的文件读取到字节

/// <summary>
/// 下载远程的文件读取到字节
/// </summary>
/// <param name="uRLAddress">文件地址</param>
/// <returns></returns>
public static byte[] DownFile(string uRLAddress)
{

WebClient client = new WebClient();
byte[] mbyte = null;
Stream str = client.OpenRead(uRLAddress);

StreamReader reader = new StreamReader(str);


using (MemoryStream ms = new MemoryStream())
{

reader.BaseStream.CopyTo(ms);
mbyte = ms.ToArray();

}
reader.Close();
str.Close();

return mbyte;

}

posted @ 2021-09-26 21:21  .net&new  阅读(61)  评论(0编辑  收藏  举报