473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

loading a file to an array in 8 bit pieces

Hi guys,

I want to load a binary file in to an array by splitting the file in 8 bit
pieces. I mean:

FileStream s = new FileStream(path, FileMode.OpenOrCreate); // Open

StreamReader r = new StreamReader(s);

string data = r.ReadToEnd();

r.Close();

the file is loaded to the string "data" as a long string, and I want to
split "data" in 8 bit pieces and save it in an array

what's the easiest way of doing it?
Nov 27 '06 #1
1 1594
Flemming Hansen <ds******@cybercity.dkwrote:
I want to load a binary file in to an array by splitting the file in 8 bit
pieces. I mean:

FileStream s = new FileStream(path, FileMode.OpenOrCreate); // Open

StreamReader r = new StreamReader(s);

string data = r.ReadToEnd();

r.Close();

the file is loaded to the string "data" as a long string, and I want to
split "data" in 8 bit pieces and save it in an array

what's the easiest way of doing it?
Do you really mean 8 bit pieces, i.e. bytes? If so, just use Stream and
read from it. See http://www.pobox.com/~skeet/csharp/readbinary.html
for a way to reliably read the entire contents of a stream.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kim Gijung | last post by:
Hi All, I got some problems for php performance. I have big php file which size is around 70K. And When i request simple one it is too slow. So i printed time stamp to find which part is slow....
3
by: woth | last post by:
Hello guys, I hope you can help me. I have the following line in my code: this.Butterfly = new Bitmap("c:\\butterfly.jpg"); which is pretty simple. The problem is that the size of...
3
by: Nathan | last post by:
Hi, I have a project with various forms that each include a number of picture boxes and panels with background images. When these forms first load, they kind of load in "pieces", with the...
1
by: bobmct | last post by:
Fellow PHP'ers; I'm digging myself a hole on this one so I thought it has come to the time when I must ask those who know. I have what should be a simple question for loading, accessing and...
3
by: Wouter | last post by:
Hi All, I am loading a web user control (.NET 2.0) into a placeholder on a content page ( plus the use of a master page). The controls is a list of companie, one you select a company for...
8
by: jhoff | last post by:
So, I'm in a pickle... Lets say I have a page: http://www.gen2host.com/discgolf/index.html and on this page, there are a list of links. These links will be generated by 5 pieces of data pulled...
6
by: Apollo1376 | last post by:
I am very new to C++. I need some help with loading/reading data from text file and write in an array. I have the following data. 12/31/2004 1213.55 1217.33 1211.65 1211.92 786900000 1211.92...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
5
by: DR | last post by:
Why is its substantialy slower to load 50GB of gzipped file (20GB gzipped file) then loading 50GB unzipped data? im using System.IO.Compression.GZipStream and its not maxing out the cpu while...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.