Hice un método rápido para escribir un archivo desde una transmisión pero aún no está hecho. Recibo esta excepción y no puedo encontrar qué:No se puede leer más allá del final de la secuencia
Unable to read beyond the end of the stream
¿Hay alguien que me pueda ayudar a depurarlo?
public static bool WriteFileFromStream(Stream stream, string toFile)
{
FileStream fileToSave = new FileStream(toFile, FileMode.Create);
BinaryWriter binaryWriter = new BinaryWriter(fileToSave);
using (BinaryReader binaryReader = new BinaryReader(stream))
{
int pos = 0;
int length = (int)stream.Length;
while (pos < length)
{
int readInteger = binaryReader.ReadInt32();
binaryWriter.Write(readInteger);
pos += sizeof(int);
}
}
return true;
}
¡Muchas gracias!
Increíble, ¡mucho más simple como dijiste! Muchas gracias :-) – TomShreds