Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 1172 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Snippet - Read StreamReader Contents In Chunks

#1
Here's a cool snippet I came up with to read using a StreamReader in chunks based on an input of how many lines you want to read at a time until the end of the Stream for the file.

Good example usage for where the null coalescing operator in C# comes in nicely as well :ok:

I used the fully fleged StringBuilder just in case we're dealing with a fair bit of lines based on the lnBufferCount for determining the buffer size for the string we're dealing with through the loop.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Enjoy
Reply

#2
So say we had a file like:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Now I can read off the data from this file in chunks of linecounts of 4 in length, which enables me to deal with these string values each time through the loop, and apply my standard action to each:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.



Example: (Using the file above)

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Result:
[Image: EOQOI.png]

[Image: vQOej.png]

[Image: 5WHcz.png]

[Image: fAegn.png]

You could even have used Regex.

Not too good with Regex, but here's an example:

Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Inside the while loop.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through