In questa porzione di codice
Codice PHP:
if ( File.Exists( "file.file" ) )
{
FileStream stream =
new FileStream( "file.file", FileMode.Open, FileAccess.Read, FileShare.Read );
BinaryReader reader = new BinaryReader( stream );
int index = 0;
while ( reader.PeekChar() != -1)
{
// Read data. Data stored in the file is the key
// The index of the key is the value
int key = reader.ReadInt32();
m_Array[ key ] = index++;
}
stream.Close();
}
Mi da questo errore la funzione PeekChar().
Codice PHP:
System.ArgumentException: Buffer dei caratteri di output troppo piccolo per contenere i caratteri decodificati. Codifica 'Unicode (UTF-8)', fallback 'System.Text.DecoderReplacementFallback'.
Nome parametro: chars
in System.Text.Encoding.ThrowCharsOverflow()
in System.Text.Encoding.ThrowCharsOverflow(DecoderNLS decoder, Boolean nothingDecoded)
in System.Text.UTF8Encoding.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, DecoderNLS baseDecoder)
in System.Text.DecoderNLS.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount, Boolean flush)
in System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex, Boolean flush)
in System.Text.DecoderNLS.GetChars(Byte[] bytes, Int32 byteIndex, Int32 byteCount, Char[] chars, Int32 charIndex)
in System.IO.BinaryReader.InternalReadOneChar()
in System.IO.BinaryReader.Read()
in System.IO.BinaryReader.PeekChar()
Mi sapreste dire se esiste un modo alternativo di capire se si è arrivati alla fine del file?
Grazie