I'm a beginner in c#.I have to read some data from binary file and convert it to text.I have written such code:
but my program shows
AAABlAAAAGQAAAAMAAAAAQAB3esBMwYQ/////wAAAAAAAAAAAAAAAAAAAAAgNS43ATFVsklOVEVMIE5UICAgIGJhdGNoX2pvRlVMTCAgICAuMSAgYm9zICAgICAgICAgAAAAAAAAAAAAAAAAAABAAAACxwoAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATWFzcz0xNTAgZmhlaWdodD00LjM3MDk5ODY1IGltcGFjdDAgTExkYW1wIDEgTFlkYW1wIDAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAscKAAAAAAAAAAAACfvxAAABlAAAAKQAAAAoAAAADAAAAAoAAAAKAAAD6AAAAAYAAAALAAAACwAAAAAAAABPAALHCgAAALYAAAiJAAAQXAAAAKgAAACbAAAcFwAAAAAAAAAAAAAAAP////8AAAABAAAAAAACxwoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKQAAAAcAAAABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAABwAAAAsAAAACgAAAAgAAAAHAAAAAgAAAAEAAAAFAAAABAAAAAMAAAAGAAAACQAAAAoAAAAsAAAAMAAAAAsAAAABAAAAAgAAAAMAAAALAAAACAAAAAkAAAAKAAAABAAAAAUAAAAGAAAABwAAADAAAB9EAAAH0AAAITkAACnGAAAyUwAAOuAAAENtAABL+gAAVIcAAF0UAABloQAAbi4AAHa7AAB/SAAAh9UAAJBiAACY7wAAoXwAAKoJAACylgAAuyMAAMOwAADMPQAA1NQAAN1rAADmAgAA7pkAAPcwAAD/xwABCF4AARD1AAEZjAABIiMAASq6AAEzUQABO+gAAUR/AAFNFgABVa0AAV5EAAFm2wABb3IAAXgJAAGAoAABiTcAAZHOAAGaZQABovwAAauTAAG0KgABvMEAAcVYAAHN7wAB1oYAAd8dAAHntAAB8EsAAfjiAAIBeQACChAAAhKnAAIbPgACI9UAAixsAAI1AwACPZoAAkYxAAJOyA==
File stores data in such format:
DUMP OF FILE= D:\batch_job.rst
RECORDS 1 TO 1000000
RECORD= 1 LENGTH= 100 LOC= 0 KBF= 100 (HEADER RECORD)
SOURCE: ANSYS PROGRAM
UNIT: 12 FILE FORMAT: External
RECORD LENGTH: 16384 FILE SIZE: 182026 SPLIT POINT: 32768
CREATION TIME: 12:23:47
CREATION DATE: 11/04/2012
RELEASE: 5.7.1 UPDATE: 20010418
SYSTEM: INTEL NT
PRODUCT NAME: FULL
JOBNAME(1:8): batch_jo
JOBNAME(1:32):
USER: bos
TITLE: Mass=150 fheight=4.37099865 impact0 LLdamp 1 LYdamp 0
SUBTITLE:
UNITS: UNDEFINED
Help me with this question.Thank you.
using (System.IO.Stream fileStream = new FileStream(@"D:/batch_job.rst", FileMode.Open, FileAccess.Read)) { using (System.IO.BinaryReader reader = new BinaryReader(fileStream)) { reader.BaseStream.Seek(0, SeekOrigin.Begin); var buffer = new byte[1000]; reader.Read(buffer, 0, buffer.Length); base64String = Convert.ToBase64String(buffer); Console.WriteLine( base64String); } }
but my program shows
AAABlAAAAGQAAAAMAAAAAQAB3esBMwYQ/////wAAAAAAAAAAAAAAAAAAAAAgNS43ATFVsklOVEVMIE5UICAgIGJhdGNoX2pvRlVMTCAgICAuMSAgYm9zICAgICAgICAgAAAAAAAAAAAAAAAAAABAAAACxwoAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATWFzcz0xNTAgZmhlaWdodD00LjM3MDk5ODY1IGltcGFjdDAgTExkYW1wIDEgTFlkYW1wIDAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAscKAAAAAAAAAAAACfvxAAABlAAAAKQAAAAoAAAADAAAAAoAAAAKAAAD6AAAAAYAAAALAAAACwAAAAAAAABPAALHCgAAALYAAAiJAAAQXAAAAKgAAACbAAAcFwAAAAAAAAAAAAAAAP////8AAAABAAAAAAACxwoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKQAAAAcAAAABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAABwAAAAsAAAACgAAAAgAAAAHAAAAAgAAAAEAAAAFAAAABAAAAAMAAAAGAAAACQAAAAoAAAAsAAAAMAAAAAsAAAABAAAAAgAAAAMAAAALAAAACAAAAAkAAAAKAAAABAAAAAUAAAAGAAAABwAAADAAAB9EAAAH0AAAITkAACnGAAAyUwAAOuAAAENtAABL+gAAVIcAAF0UAABloQAAbi4AAHa7AAB/SAAAh9UAAJBiAACY7wAAoXwAAKoJAACylgAAuyMAAMOwAADMPQAA1NQAAN1rAADmAgAA7pkAAPcwAAD/xwABCF4AARD1AAEZjAABIiMAASq6AAEzUQABO+gAAUR/AAFNFgABVa0AAV5EAAFm2wABb3IAAXgJAAGAoAABiTcAAZHOAAGaZQABovwAAauTAAG0KgABvMEAAcVYAAHN7wAB1oYAAd8dAAHntAAB8EsAAfjiAAIBeQACChAAAhKnAAIbPgACI9UAAixsAAI1AwACPZoAAkYxAAJOyA==
File stores data in such format:
DUMP OF FILE= D:\batch_job.rst
RECORDS 1 TO 1000000
RECORD= 1 LENGTH= 100 LOC= 0 KBF= 100 (HEADER RECORD)
SOURCE: ANSYS PROGRAM
UNIT: 12 FILE FORMAT: External
RECORD LENGTH: 16384 FILE SIZE: 182026 SPLIT POINT: 32768
CREATION TIME: 12:23:47
CREATION DATE: 11/04/2012
RELEASE: 5.7.1 UPDATE: 20010418
SYSTEM: INTEL NT
PRODUCT NAME: FULL
JOBNAME(1:8): batch_jo
JOBNAME(1:32):
USER: bos
TITLE: Mass=150 fheight=4.37099865 impact0 LLdamp 1 LYdamp 0
SUBTITLE:
UNITS: UNDEFINED
Help me with this question.Thank you.
Last edited by a moderator: