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

/// <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;

}

上一篇:提高 Java 效率的 35 个小技巧,用了的都说好!


下一篇:如何定义和使用接口?