TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ram Prasad
NA
326
18.1k
Dividing the data in text file into smaller chunks
Apr 29 2020 12:36 AM
I am working on this program where I have defined a class value which takes data from a text file. Right now my program is taking the whole data, processes it and then is used in further calculation in Main().
I want to divide the incoming data into smaller data chunks and perform the calculation one by one.
For Ex: lets say I have 2048 bits in .txt file, this data gets divided into 4 chunks of 512 bits each. After division Chunk 1 is used in furhter calcualtion in Main(), after that program comes back o pick Chunk 2 and do the calculation and similar with Chunk 3 and Chunk 4. How can I do that? Please advise
public static byte[] GetValue()
{
byte[] numbers = new byte[2048];
using (FileStream fs = File.Open(@"C:\Users\file1.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (BufferedStream bs = new BufferedStream(fs))
using (StreamReader sr = new StreamReader(bs))
{
string line;
while ((line = sr.ReadLine()) != null)
{
for (int i = 0; i < 512; i++)
{
numbers[i] = Byte.Parse(line[i].ToString());
}
}
}
return numbers;
}
Reply
Answers (
1
)
how to get first folder name from a file path??
Delete and save in table from Entity Framework