【发布时间】:2011-10-12 18:05:43
【问题描述】:
我正在实现一个接受图像流的 wcf 服务。但是,当我运行它时,我目前遇到了异常。因为它试图在流完成之前获取流的长度。所以我想做的是缓冲流直到它完成。但是我找不到任何如何做到这一点的例子......
谁能帮忙?
到目前为止我的代码:
public String uploadUserImage(Stream stream)
{
Stream fs = stream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);// this causes exception
File.WriteAllBytes(filepath, bytes);
}
【问题讨论】:
-
异常类型和消息是什么?