Example #1
0
        public void leeArchivo()
        {
            string ubicacion;
            try
            {
                Console.WriteLine("Dame la ubicacion de el arcihvo");
                ubicacion = Console.ReadLine();

                StreamReader objReader = new StreamReader(ubicacion);
                objReader.GetType();

                string sLine= objReader.ReadLine();
                ArrayList arrText = new ArrayList();

                    while (sLine != null)
                    {
                        agregaResisgtro(sLine);
                        sLine = objReader.ReadLine();
                    }
                     objReader.Close();

            }
            catch(Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
                Console.WriteLine("Cerrando la lectura.");
            }
        }
Example #2
0
    private static long GetCharposMono3(StreamReader s)
    {
      Int32 charpos = (Int32)s.GetType().InvokeMember("pos",
      BindingFlags.DeclaredOnly |
      BindingFlags.Public | BindingFlags.NonPublic |
      BindingFlags.Instance | BindingFlags.GetField
      , null, s, null);

      Int32 charlen = (Int32)s.GetType().InvokeMember("decoded_count",
      BindingFlags.DeclaredOnly |
      BindingFlags.Public | BindingFlags.NonPublic |
      BindingFlags.Instance | BindingFlags.GetField
      , null, s, null);

      return s.BaseStream.Position - charlen + charpos;
    }
        private static long GetStreamReaderPreambleSize(StreamReader sr)
        {
            if (_streamReaderPreambleProperty == null)
            {
                _streamReaderPreambleProperty = sr.GetType()
                                                  .GetProperty("Preamble_Prop",
                                                               BindingFlags.Instance | BindingFlags.NonPublic);
            }

            return ((byte[])_streamReaderPreambleProperty.GetValue(sr)).Length;
        }
Example #4
0
        public long GetActualPosition(StreamReader reader)
        {
            // The current buffer of decoded characters
            char[] charBuffer = (char[])reader.GetType().InvokeMember("charBuffer"
                , System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField
                , null, reader, null);

            // The current position in the buffer of decoded characters
            int charPos = (int)reader.GetType().InvokeMember("charPos"
                , System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField
                , null, reader, null);

            // The number of bytes that the already-read characters need when encoded.
            int numReadBytes = reader.CurrentEncoding.GetByteCount(charBuffer, 0, charPos);

            // The number of encoded bytes that are in the current buffer
            int byteLen = (int)reader.GetType().InvokeMember("byteLen"
                , System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField
                , null, reader, null);

            return reader.BaseStream.Position - byteLen + numReadBytes;
        }
        private static int GetStreamReaderBufferPos(StreamReader sr)
        {
            if (_streamReaderBufferPositionProperty == null)
            {
                _streamReaderBufferPositionProperty = sr.GetType()
                                                        .GetProperty("CharPos_Prop",
                                                                     BindingFlags.Instance | BindingFlags.NonPublic);
            }

            return (int)_streamReaderBufferPositionProperty.GetValue(sr);
        }
        private static long GetStreamReaderBufferLength(StreamReader sr)
        {
            if (_streamReaderByteLenProperty == null)
            {
                _streamReaderByteLenProperty = sr.GetType()
                                                 .GetProperty("ByteLen_Prop",
                                                              BindingFlags.Instance | BindingFlags.NonPublic);
            }

            return (int)_streamReaderByteLenProperty.GetValue(sr);
        }