当前位置: 代码迷 >> ASP.NET >> 根据文件url如何实现将文件读入byte[] buffer中
  详细解决方案

根据文件url如何实现将文件读入byte[] buffer中

热度:8569   发布时间:2013-02-25 00:00:00.0
根据文件url怎么实现将文件读入byte[] buffer中?
根据文件url怎么实现将文件读入byte[] buffer中?
知道的大神,赶紧指条明路吧
------解决方案--------------------------------------------------------
引用:
根据文件url怎么实现将文件读入byte[] buffer中?
知道的大神,赶紧指条明路吧

就是本地下载网上文件
------解决方案--------------------------------------------------------
webclient直接down为stream
------解决方案--------------------------------------------------------
 byte[] photo_byte = null;
//strFile 
            using (FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    photo_byte = br.ReadBytes((int)fs.Length);
                }
------解决方案--------------------------------------------------------
引用:
webclient直接down为stream

DownloadData("");返回byte[]  没有返回stream的吧。用webclient大一点文件会超时,有没其他的方法?
------解决方案--------------------------------------------------------
  string url = "文件地址";
             WebClient wb = new System.Net.WebClient();
             var photo_byte = wb.DownloadData(url);
------解决方案--------------------------------------------------------
引用:
byte[] photo_byte = null;
//strFile 
            using (FileStream fs = new FileStream(strFile, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader br ……

FileStream 读的是本地文件路径。我需要http路径。
------解决方案--------------------------------------------------------
引用:
string url = "文件地址";
             WebClient wb = new System.Net.WebClient();
             var photo_byte = wb.DownloadData(url);

我用的就是这个,1M左右文件正常,大一点就超时了
  相关解决方案