using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(filename, FileMode.Create, isf))
{
using (BinaryWriter writer = new BinaryWriter(fileStream))
{
var length = stream.Length; //此处可得到值194777
var buffer = new byte[1024];
int readCount = 0;
using (BinaryReader reader = new BinaryReader(stream))//此处是WP7图片选择器返回的stream
{
while (readCount < length)
{
int actual = reader.Read(buffer, 0, buffer.Length);//读到此处直接返回0
readCount += actual;//导致readCount 永远为0,死循环
writer.Write(buffer, 0, actual);
}
}
}
}如何解决
stream的Length长度不为0,Read的结果为0,估计是因为已到达stream的末尾,可以用Seek定位到开始
的确是这样,问题已经解决谢了