Questions tagged [binaryreader]

In .net is a class used to read binary values. In general, it is a class or a program to read and manipulate binary data.

244 questions
3
votes
1 answer

How to use BinaryReader Read method to read dynamic data?

I'm trying to use a BinaryReader Read method in a generic way. Only at run time I know the type of data being read. public static T ReadData(string fileName) { var value = default(T); using (var fs = new…
Monica
  • 223
  • 1
  • 3
  • 14
3
votes
1 answer

What is the efficient way to search for a hex-value in a big binary file in C#

Much like the same functionality in HxD editor, I am implementing a program that searches for a specific hex-value (say 32 bits) in a big binary files (> 1 GB). Memory is limited and it seems that reading chunk by chunk is quite slow with…
Zeiga
  • 201
  • 4
  • 14
3
votes
1 answer

Visual Basic.NET "The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System

I am trying to read a binary file in which i have been appending data using a BinaryWriter object. I keep getting this error: "The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback …
Kevin Ledama
  • 131
  • 2
  • 7
3
votes
3 answers

Converting from byte[] to string

I have the following code: using (BinaryReader br = new BinaryReader( File.Open(FILE_PATH, FileMode.Open, FileAccess.ReadWrite))) { int pos = 0; int length = (int) br.BaseStream.Length; while (pos < length) { b[pos] =…
zack
  • 7,115
  • 14
  • 53
  • 63
2
votes
2 answers

What is the Best way to deserialize a null-terminated string in .NET?

I am reading a message from my network connection which is serialized as a series of null-terminated strings (and other binary data) I could read a char at a time using a BinaryReader, until I find a NULL. Is there a more efficient way that is still…
theschmitzer
  • 12,190
  • 11
  • 41
  • 49
2
votes
6 answers

BinaryWriter problem - "code adds some byte between Write() method"

I am try to do some code using BinaryWriter and Then BinaryReader. When I wanna write I use method Write(). But the problem is that between two lines of Write method there appears a new byte which is in ASCII table in decimal 31 (sometines 24). You…
Mitja Bonca
  • 4,268
  • 5
  • 24
  • 30
2
votes
2 answers

Read and write of binary file in c#

I have read a binary file in using C# as per the following code. Then I tried to write this binary data in another binary file. But I found that when I opened these 2 files in Winmerge, there is a difference in both binary files. i.e read file and…
Ganesh Chavan
  • 57
  • 1
  • 1
  • 6
2
votes
2 answers

Edit or remove PDF header information in C

I need to edit the header information of several PDF files. What I'd like to achieve is to remove all header data before %PDF-X.Y.Z. What I came up with as a possible solution was to open the PDF in binary mode, read each character until %PDF-X.Y.Z…
Dominik
  • 117
  • 1
  • 1
  • 10
2
votes
2 answers

How do I read a binary file in C#?

I have a file that exists within a text and a binary image, I need to read from 0 to 30 position the text in question, and the position on 31 would be the image in binary format. What are the steps that I have to follow to proceed with that…
mcamara
  • 731
  • 4
  • 15
  • 26
2
votes
2 answers

C# Winforms Log-In Form using Binary File

I am currently working on a school project that will have your classic log-in/register form. The project requires that we include a binary file to 'securely' store each User's information e.g username, password etc. I am successfully writing new…
2
votes
3 answers

Binaryreader read from Filestream which loads in chunks

I'm reading values from a huge file (> 10 GB) using the following code: FileStream fs = new FileStream(fileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); int count = br.ReadInt32(); List numbers = new List(count); for…
user2033412
  • 1,950
  • 2
  • 27
  • 47
2
votes
2 answers

How do I read shorts from a binary file starting at position x, for y values?

I need to read a certain amount of short (int16) data points from a binary file, starting at a specific position. Thanks!
cabgef
  • 1,398
  • 3
  • 19
  • 35
2
votes
0 answers

Using Marshaling and a BinaryReader to parse a file that defines its own structure

I am working on reading a binary file that is comprised of numerous data block, each defined by a struct. Each block begins with a unique signature to indicate what kind of data is to be read, and which I can also use to determine the length of the…
2
votes
1 answer

What is the best way to read the uploaded files from Request.Files, StreamReader or BinaryReader or BufferedStream?

I have a form where the user can upload multiple files. I am using MVC 2.0 and in my controller I need to call a webservice that is a common import interface requires the files to passed in as byte[]. .NET exposes Request.Files as a…
R N
  • 73
  • 4
2
votes
3 answers

C# Process Binary File, Multi-Thread Processing

I have the following code that processes a binary file. I want to split the processing workload by using threads and assigning each line of the binary file to threads in the ThreadPool. Processing time for each line is small but when dealing with…
washtik
  • 215
  • 1
  • 4
  • 7