• Breaking News

    Sunday, May 31, 2020

    What have you been working on recently? [May 30, 2020] learn programming

    What have you been working on recently? [May 30, 2020] learn programming


    What have you been working on recently? [May 30, 2020]

    Posted: 30 May 2020 09:04 AM PDT

    What have you been working on recently? Feel free to share updates on projects you're working on, brag about any major milestones you've hit, grouse about a challenge you've ran into recently... Any sort of "progress report" is fair game!

    A few requests:

    1. If possible, include a link to your source code when sharing a project update. That way, others can learn from your work!

    2. If you've shared something, try commenting on at least one other update -- ask a question, give feedback, compliment something cool... We encourage discussion!

    3. If you don't consider yourself to be a beginner, include about how many years of experience you have.

    This thread will remained stickied over the weekend. Link to past threads here.

    submitted by /u/AutoModerator
    [link] [comments]

    The misconceptions of a programmer's life

    Posted: 30 May 2020 04:38 AM PDT

    I see frequent posts from beginning programmers wondering what programming is like, and I think it's useful to address those issues.

    You program 8 hours a day at work

    This is probably the least true of all the things. Most programming jobs are maintenance jobs. The programs have all mostly been written years ago, and you are doing support, minor enhancements, bug fixes. Even if you get to do more than that, you are still not likely coding a large part of your day. It's about meetings to decide what to do.

    Also, from my experience, unless you have some reason to dig deep into code (esp. if the code base is large), most people don't bother. Our codebase is old and rickety. There aren't comments. The business process isn't exactly documented. I don't want to wade through 2000 lines of Java code (per Java file) and try to understand the business behind it.

    Unless you're working in a brand new project that needs a lot of code written (which I've been in), you are probably not doing a lot of programming.

    A program is about programming

    I work at a university. Students, esp. computer science students, complain about our old system that runs a "batch style" programming system. That is, the system shuts down overnight, does a bunch of data processing, and opens again in the morning. They wonder why the system can't be Facebook or Google or YouTube, and be up 24 hours a day.

    First, I think many such people would be surprised how many people (or really, how few people) are supporting these systems. You'd think there's a team of 20 developers doing the best they can to keep this stuff running, and it's like a well-oiled machine, but sometimes it's less than half a dozen people, and we barely know the software's purpose, but can do minor fixes and keep stuff running.

    Most software out there isn't, as they say, rocket science. Sure, a few exceptions (say, SpaceX software). Most of the software encodes business practices, and most business practices are a weird arcane set of rules that have no basis in math or science, but is just how some company works. You write that in code, no matter how illogical it is. And often, the code, and a few old timers' memories are what holds the project together.

    Comments? Hah! A written business process? Hah! Programmers had one purpose: get the program to work. They didn't think about who would maintain the code after they retired. The only saving grace was their background wasn't so sophisticated as to create true spaghetti code (let's use regular expressions and finite state machines and design patterns up the wazoo!).

    It's often not the coding language (like Cobol) that prevents modernization (although it's partly that), it's that the business process was never formalized, and there are 100,000 lines of code no one wants to read (and only represents an approximation of what the people who wanted the code wanted---and they're retired too!).

    I often point out the scene in the third Matrix movie where the councilman is talking to Neo about how these machines support their underground city, yet no one quite knows who built it or how it works. That's a lot of software out there.

    Writing from scratch is not such a common experience (at least, from my perspective), and even when you do, it's not always as organized as it could be. We may call it software engineering, but most engineering involves others looking at your work, and having input into fix it. Code reviews aren't the same thing as people inspecting a building and seeing it every day.

    We often don't rewrite things because the rewrite would be huge, would require a bunch of new developers, and doesn't even have the support of the people we're writing it for.

    As a programmer, since I wrote the code, my opinion is the most important

    OK, so you may know programming, but do you know the business you're working in? Many a programmer or startup guy thinks "You guys do something dumb, and I'm smart, so I can easily create a system that's 10 times better than the crap you use. And you know what? I'm not even going to consult you about how the system should work. I'll make up my own. You are such idiots!".

    Well, that may be, but they're used to the system they are used to, and they've thought about their own (arcane) business process for a long time, and if you build something that is completely different from what they are used to, they won't say "oh, we lack the intellect to understand your truly great software", they'll just not use your software.

    If your user base is a bit older, and possibly, even if they aren't, they will be used to doing things in a certain way. Maybe you can convince them that way isn't smart, but if they questioned your lack of comments, your lack of coding structure, how what you wrote seems like gibberish, you might get defensive as well.

    The point is that you're often writing software or maintaining software by those who use the software every day. As a programmer, you might even have the luxury to walk away after you write a code, never having used the code as your users use them, and they may ultimately hire someone new who maybe pays attention to what they actually want, even if you think it makes no sense.

    The program matters

    Many of you are learning to program. You think companies are willing to throw out a million line codebase because it's written in an obsolete language. Who's going to write it? You? (You, Mr. Wineburg?)

    A million lines of code is something that could take a lifetime to rewrite. Do you plan to read the code to understand what it does? Could you even do that?

    In any case, sometimes people think the program is king (or queen, or some elected position). It's not.

    It's the data.

    Say you've run this legacy program for more than a decade. It fills up tables and table of data. You, being a person who hates legacy code, wants new DB tables, and new ways of storing information.

    Here's the problem. What do you do with all that old data? Oh, you want to throw it out? Start new? Brilliant!

    Every software shop is the same

    If you look at the world of practicing doctors, they seem to fall (roughly) into two categories: those working in hospitals on patients that need somewhat urgent care (or are doing elective surgery), and doctors with private practices.

    Both seem to follow a similar structure, so that if you went from one personal care doctor to another, their structure would be about the same (waiting room, receptionist, files, someone to check your insurance, collect your copay). If you go get your car repaired at a mechanic, you expect a similar experience. If you go to a grocery store, you expect a similar experience.

    People in the software industry have nothing close to this. Each company may have widely varying setups. There are companies with just one programmer that does everything. Could you run a grocery store with just one person? (Well, maybe if it's a tiny one person operation selling very few items). Or a doctor's office (probably not because of insurances, unless you're some kind of boutique doctor that makes home visits, and even then, I suspect you're hire someone to do the billing, etc).

    The big companies can afford to have their own internal support structure that makes it easier for their average developer to deploy code. That support structure is often an internal thing, not an off-the-shelf, any small company can do it. If you were a car mechanic and wanted to open your own small shop, you'd probably know exactly what you need (at least, the very basics). These things probably have been (roughly) the same for decades, and even the new things, people probably generally agree on what is needed.

    But if you're a small software shop...there's no such standards. Do you want to use Atlassian tools? Or do you use a spreadsheet, or emails? Do you use some kind of company email? Or do you use personal email? There are lots of decisions, and it's hardly standardized in the industry.

    You may think, say, version control is important. I guarantee there's some software out there (maybe rare), that doesn't use standard version control, and it probably does something important. And the people maintaining it may not even understand what version control is and why you need it. I'm serious.

    It's like going to a surgeon with a bottle of whiskey and a bowl of leeches and they say "What's anaesthetic?"

    We'll rewrite everything!

    "I know engineers, they love to change things--Dr. McCoy, Star Trek: The Motion Picture"

    Back in the 1990s, the skill most programmers needed? The ability to read other people's programs. Most early programmers could write code, but they really had a hard time reading code, so they were almost always complaining that you needed a complete code rewrite to write that code in a way they could understand, without realizing the irony that the next programmer would want to throw away their code, and write it from scratch.

    Joel Spolsky, who used to blog many years ago (Joel on Software), used to say rewrites were basically evil. A functioning codebase should have been tested many times and many bugs have been removed. A new codebase will introduce new bugs and will be buggy. Software engineers aren't that good about creating bug-free code (after all, what is a bug? are there specs?). He said it's better to refactor to improve the code than to rewrite, but most developers like the feeling of an albatross of code off their neck that they don't care about bugs they introducing.

    New code is wonderful!

    But realistically, you need to know what you're building, and knowledge of the ins and outs of a programming language doesn't help you figure out what it is you're building. And sometimes your experts also want to control the kind of software you're writing (mostly from a usability standpoint).

    I only have to understand a programming language

    Many self-taught programmers think "it's all about learning a programming language".

    Some complain: why do I need to know HTML? Why do I need to know CSS? Why do I need to know SQL? Why do I need to know version control? Why do I need to know Github? Why do I need to know math? Why do I need to know business? Why do I need a deploy system? Why can't someone else test my code? Why do I need a bug tracking/task tracking software? Why do I need to read my emails? Why do I need to update my tickets?

    It's hard enough for most of you to learn a programming language. But it's often the tip of the iceberg. To support web programming, many programming languages have a web framework, and sometimes those web frameworks do a lot of magic, to "help you out", and now, you thought you understood how a programming language works, but you don't. (We used annotations, you'll love how it's not crufty like the rest of Java!)

    Conclusions

    • You don't program hours a day unless it's brand new software, and even then.
    • You'll probably spend as much time in meetings (if you get to be important enough) than programming.
    • There are generally two kinds of developers that survive in a company/organization that's been around a while: those with strong technical skills, and those that have been around long enough to understand how things work (business-wise) even if they lack the technical chops. Sometimes (rarely), they are the same person.
    • You don't need to know computer science that well to write software that basically works, esp. if you know the business well. A lot of software may require only basic math skills and some understanding of how the web works. It's sort of the equivalent of a doctor that learned how to doctor online, and only learned 10% of what they should. They may still be able to heal most basic things, but not be able to do some other basic stuff. We don't trust that in doctors, but in software, it might be OK.
    • Knowing the business is often at least as knowing the software, possibly more important.
    • Your customers likely don't want you to make "improvements" to their software, esp. those that you didn't bother to consult them with.
    • Most people tend to do maintenance programming, not green field (brand new) coding.
    • You often have to teach yourself newer technologies. Your senior developers aren't usually willing to be teachers and teach you from scratch.
    • Communication skills are useful, but most developers became developers because they prefer to work alone. This doesn't always lead to good software, no matter how skilled the person is.
    • You shouldn't think you're writing code for yourself, but for the next person that has to maintain it. Don't be too clever. Someone else will have to deal with your code (and it could be you, two years later). Maybe write some comments or something.
    • Software can be developed in all sorts of ways, many not approaching "best practices" (which seems to change all the time). Not everyone is on the cutting edge (see New Jersey Cobol programs for filing unemployment). Being on that edge requires chasing a moving target that most companies think is a waste of time (why does Spring keep coming out with new versions--haven't they figured it out by now?). This means that there is no typical way software is developed. Yes, many companies share similarities (they have a Wiki, they use Jira, they use Bitbucket, they have a deploy system, they do code reviews), but it's not universal.
    • Your code is often not reviewed as much as it should, and you might get defensive about the comments you get.
    • Code consistency helps (if you can tell who wrote the code based on stylistic choices, that may not always be the best thing).
    submitted by /u/CodeTinkerer
    [link] [comments]

    An amazing way to study new Languages (Beginners)

    Posted: 30 May 2020 09:51 AM PDT

    I stumbled upon this video after getting annoyed with Javascript. I started using this tactic and I notice my retention with new concepts. For those who don't feel like watching a video, here is a summary.

    It talks about how you should ask questions about your code, and as many you can think of for given line.

    What does console.log do? What does the console mean? What does log mean? how about the period in the middle, what does that do?

    This is just an example. It can be used for chunks of functions and even algorithms.

    Study code slow. Understand what it actually does, and not just the syntax.

    "It's not about how much you can cover in one day, it's about how much you can remember."

    https://www.youtube.com/watch?v=bKQwmP_T-oc

    submitted by /u/ADSchmidtofficial
    [link] [comments]

    Learn Python on AWS

    Posted: 30 May 2020 11:54 PM PDT

    Learn Python on AWS

    I have written a Learn Python On AWS for total beginners. It uses AWS resources such as the Cloud9 IDE and the Amazon Translate service to teach you the basics of the Python language.

    Learn to Code

    submitted by /u/charles545587
    [link] [comments]

    Questions about packages in Java

    Posted: 30 May 2020 11:15 PM PDT

    From my understanding a package is a file containing classes or a class. If a package is not specified, then we have something called a default package. What is the scope of default packages? If I have two projects in Eclipse each having no specified package, meaning using a default package, are they using their own separate instance of default package?

    If I import a package to another class, when does the code get brought in and get ran from the other package, is it during compile time or runtime? How does that work?

    Where do the packages such as java.lang or java.util belong? Why is it that java.lang package is already imported by default but the java.lang is not if both belong the java directory?

    If I wanted to connect two projects in eclipse, would I just import one of the packages from one project to another to connect them?

    submitted by /u/RoundCheek1
    [link] [comments]

    6.0001 on MIT-OCW

    Posted: 30 May 2020 10:57 PM PDT

    Hi everyone.

    I am a rising sophomore enrolled in a CS degree in India. I recently took 6.0001 on MIT-OCW and edX - lectures from edX and assignments from OCW(assignments are exactly the same on both).

    For those of you who don't know, 6.0001 is a half semester long MOOC offered by MIT. It is called - "Introduction to Computer Science and Programming in Python". I assume a lot of you guys wanted to know what the course is like. So I wrote a blog!

    Here is my blog - https://medium.com/@palashsharma891/my-experience-with-6-0001-on-mit-opencourseware-6ea1c43e3c3d

    Here is my GitHub, where I posted all my answers - https://github.com/palashsharma891/6.0001---MIT

    Have a nice day!

    submitted by /u/polopower69
    [link] [comments]

    Is an array a data structure or a data type?

    Posted: 30 May 2020 05:37 PM PDT

    I see both terms being used for it online, is it both? Does it depend on a language?

    submitted by /u/CrazyLock6
    [link] [comments]

    Rounding Doubles (Java)

    Posted: 30 May 2020 08:17 PM PDT

    In my program I'm rounding doubles to whole numbers before making them ints. Is there a way to round one number of a given input?

    submitted by /u/KingVsGamin
    [link] [comments]

    C# Random error on closing bracket

    Posted: 30 May 2020 11:41 PM PDT

    in this code: https://codeshare.io/2jdz0v there is a random error on the closing bracket on line 83 and i cant figure out why. Help please.

    submitted by /u/SputterSizzle
    [link] [comments]

    C++ Program Help (segmentation fault)

    Posted: 30 May 2020 11:40 PM PDT

    Hello

    I've been working on a command line chess program, and all's been going well up until this point. Whenever I run the program, I get a segmentation fault after the 'display' function is processed for the second time. I think the error is somewhere between lines 88 and 113 and has something to do with the program attempting to access a non-existent location in the 'board' array, but I'm not sure what specific instruction in the program is doing this. Can someone help me figure this out?

    What the program is supposed to do after processing the 'display' function for the second time is prompt the black side player for input on the move they want to do.

    The source code of the program in question: https://pastebin.com/sJ5uzQk5

    This is the first program I've written outside of any of my programming classes, so while I attempted to format it to be readable there's most likely room for improvement on that front.

    Thanks for any help you give me.

    submitted by /u/SilverFox-41
    [link] [comments]

    (C#) Two errors that i cannot figure out

    Posted: 30 May 2020 11:14 PM PDT

    In this code: https://codeshare.io/2jdz0v there are two errors that i cannot figure out. any help?

    submitted by /u/SputterSizzle
    [link] [comments]

    To Experienced Devs: How important is it to follow a coding paradigm or maintain clear and structured code?

    Posted: 30 May 2020 11:10 PM PDT

    I'm a fresh grad with a CS degree. During my internship, I noticed that writing clear and legible code was very important. However, that was rarely followed when working on a group project in college.

    As the pandemic is still going on, I am working on side projects with my job joining date delayed. But I have the same coding style. I dont really refactor the code to make it legible. I wouldn't say I write horrible code but I also have gotten rejected from FAANG company due to poor coding style.

    Can you give me some tips/advice?

    submitted by /u/something12355
    [link] [comments]

    Novice Programmer - I suspect I've been offered a job way out of my league? Help

    Posted: 30 May 2020 11:05 PM PDT

    An old coworker heard that I've started learning to program recently (end of last year), and he's currently working on a new business project that will need an IOS&Android-hybrid app developed.

    He has a really well drawn out idea of how he wants the finished design to look and interact, and it can be boiled down to:
    - Stripped down version of TripAdvisor's "Book a tourist Experience"
    - The ability for businesses to post their events with prices
    - A login system for both customers and businesses
    - A search bar that can filter events based on when it takes place, where or price.
    - It should be possible to pay both by card in-app, and by an implemented API from our countries biggest phone-banking system. (This particular point sounds like a big challenge to me)
    - No need for multilingual support

    He says he doesn't necessarily need to have sleek animations or such, it doesn't need to accommodate more than perhaps 10 000 users, no videos, no leave-a-review system.

    But he'd preferably have it done before the end of 2020.

    Question: Is this a job that in your eyes could be feasible for a single "novice" programmer to accomplish in 6 months - if it was worked on as a paid full-time job?

    He seems to be very understanding of my beginner-status, but even though it seems like a possible project in my ever-optimist-mind, I'd love to hear some real feedback before I make a commitment that might just have been clearly doomed to fail from the very beginning.

    submitted by /u/Refleksjon
    [link] [comments]

    if this is possible - what is the simplest way to track the relative motion of a phone over a desk by using the camera on it?

    Posted: 30 May 2020 07:04 PM PDT

    Hi, I'm not sure if this is possible but I would like to track the relative motion of a phone as it is held and moved over a desk. By relative motion I mean up and down or left and right.

    I looked at what the footage looks like, and I see that web apps have access to the front or rear cameras (if they request it).

    What would the simplest way be for me to track the relative motion of the phone over the desk, if this is possible? (Such as if the user moves it down, which would cause a zoom-in like effect, moves it up, which would cause a zoom-out like effect, or if the user pans it, moving it straight left or right.)

    I did try to see what it would look like if rather than being over a desk looking downward it looked out at the room, but there is very little motion in that case, as the user moves it, hence why I am asking about looking down straight at the desk.

    I'm not a super whiz, so I'd just like to know what the simplest solution would be for getting this motion data - if it is possible!

    Thank you.

    submitted by /u/simplerizbetter
    [link] [comments]

    Are setup options a good place to use duck typing?

    Posted: 30 May 2020 10:45 PM PDT

    I have a SetupWizard class for a node CLI app I'm developing. it will have steps to setup a Google Cloud role, enable APIs, and add options to a config file.

    I have low experience with polymorphism and am looking for an opportunity to practice duck typing. Does it make sense to setup a subfolder classes/setupOptions, and include in this folder name.ts, account.ts to handle printing wizard information to the CLI and validation? Inside SetupWizard I could then setup generic methods to printInstructions, validate and save using duck typing.

    class SetupWizard { public printInstructions<O>(optionClass: O) { console.log(optionClass.instructions) } } 

    Syntax may not be correct, I'm new to generics and am just trying to convey the overall idea.

    If this is a bad pattern I'm curious why.

    submitted by /u/fpuen
    [link] [comments]

    Is there any way to have the game engine/application limit how much hardware you're using? As in, emulating what it would be like to develop for an old system or console.

    Posted: 30 May 2020 10:43 PM PDT

    Yes, I do understand that things like fantasy consoles exist, but that isn't exactly what I'm thinking. Let's say that you want to make an engine that a user can put limitations on what he can do. As in, emulating developing for old hardware like an old console. Would that be possible? I would think it would be robust like developing for old systems, but with the benefit of not having to purchase that system which can get pretty pricey. I'd be using C, though I am still a beginner and I'm just curious. Thanks so much for the help! Apologize if it's a rather dumb question.

    submitted by /u/skully111
    [link] [comments]

    [C++] error: expected initializer before '/=' token

    Posted: 30 May 2020 10:23 PM PDT

    So, this is probably me being dumb and just missing something simple, but I cannot figure out why I am getting this error, and after searching through some stack overflow posts, most of the results that came back were the result of incorrectly declaring functions (which I haven't used in this code. The error in the title is occurring on all four of the following lines (program is a simple project I made this morning, still learning the very basics, and this error is occurring from me trying to make the code less messy)

     int flour_owned /= flour_needed; int sugar_owned /= sugar_needed; int milk_owned /= milk_needed; int eggs_owned /= eggs_needed; 

    I really am not sure where I have gone wrong here, so if someone could point me in the right direction for fixing it, I would be really appreciative. Thanks.

    Full code can be found here, didn't want to make the post too long: https://pastebin.com/ZxjqS5ip

    Edit: I have realised that I am dumb, and that telling the program to do math on a variable doesn't require me to call int again, lesson learned, don't try coding based on ideas your insomnia filled 5 AM brain thinks of.

    submitted by /u/Mobius_1_OW
    [link] [comments]

    Can I get some advice on how to structure my database with a few static fields and one field that keeps getting updated?

    Posted: 30 May 2020 09:57 PM PDT

    Not sure my title was clear, sorry.

    I'm building a reddit bot as a python learning exercise. The purpose is to download reddit posts and then keep an eye on them to see which ones are increasing their comment count the fastest.

    So I'm fine on downloading the post IDs, titles, and any other data I need from reddit and storing them in SQLite the first time, but then the program will keep checking their comment count and storing the number of comments.

    I'll then look at the series of comment counts for a particular post and see how fast they are increasing over time.

    Does anyone have any suggestions on how to store the comment counts? Should I do a post_table with the posts, and then a count_table with the comment count indexed to the post IDs in the post_table?

    Appreciate any help, thanks!

    submitted by /u/Subduction
    [link] [comments]

    Setting up C environment in Windows

    Posted: 30 May 2020 09:34 PM PDT

    Hello Reddit!

    New member and looking to set up an environment in a Windows environment using a coding terminal/editor. As of now I have downloaded Visual Studio Code, and am looking to set it up as best as possible for the C programming language.

    Also, does anyone know of any good free resources? I will be taking a class during the fall over C and am trying to jump ahead and learn as much as possible, never hurts to be ahead and try my best at learning practical skills.

    Thank you!

    submitted by /u/3X01
    [link] [comments]

    Help me with this programming question from c primer plus sixth edition

    Posted: 30 May 2020 09:29 PM PDT

    All the question says is "fix this silly program" ( the / in c means devision.)

    Void main(int) { Cows, legs integer; Printf("how many cows legs did you count?\n); Scanf("%c", legs); Cows = legs / 4; Printf("that implies there are %f cows. \n, cows) }

    submitted by /u/expectoid17
    [link] [comments]

    I have a question about tools to track my time for coding questions

    Posted: 30 May 2020 05:33 PM PDT

    I've been practicing coding technical questions on different platforms (Leetcode and HackerRank). I've found my approach and the time it takes has been inconsistent with my experiences in actual interviews.

    1) Are there any guidelines on the process of answering these questions? (Time breakdowns for formulating an algorithm, test cases, time analysis, code, and final review)

    2) Are there any tools (app or chrome extension) to track my performance/time while I practice answering questions on the coding platforms?

    I want to simulate the process of problem-solving coding questions in technical interviews outside of mock interviews. Just practicing the coding technical question is not enough for me, as it is easier to solve the questions without any pressure.

    Thanks in advance!

    submitted by /u/PhilosophicalTyrant
    [link] [comments]

    Scrapy HTTP Request error when trying to send request login on nike site

    Posted: 30 May 2020 05:25 PM PDT

    Im trying to make a sneaker bot for nike snkrs brazil site (nike.com.br/snkrs) using scrap. So firt i tried to make a spider that logins into the site, i see that have some login requests on the network so i tried to send the ones that i think that is needed.

    Here is the full code of the spider:

    https://pastebin.com/Xke6kP1P

    But when i tried to crawl the spider to test i get some http request errors like 400 Bad Request, 401 POST HTTP Request not handle or allowed or 403 Forbidden. Here is the full error code:

    https://pastebin.com/ge9pr6qx

    I already using proxy ip and user agent rotation middlewares but still get these errors.

    submitted by /u/EsauSantos9
    [link] [comments]

    Looking for any css improvements I can make on this small website I made.

    Posted: 30 May 2020 08:54 PM PDT

    https://jsfiddle.net/cq28bgs6/1/

    I know the colors are off, I just added different colors in to differentiate each section.

    submitted by /u/fizzbuzzstar
    [link] [comments]

    What is a good intermediate-advanced c++ crash course?

    Posted: 30 May 2020 04:50 PM PDT

    I have about a month to prepare for a competitive programming challenge and I want to switch to c++(from Java) what can you recommend? I'm willing to give 10 or 15 dollars but no more (obviously being free would be a plus).. Thanks

    submitted by /u/Kostas1507
    [link] [comments]

    C#: Integer overflow and reading files

    Posted: 30 May 2020 08:33 PM PDT

    So I'm trying to read a file in blocks and store them so I can send them over the network later. The issue is that the size of the file in bytes is larger than the maximum integer value and stream.Read() only accepts 32 bit integers for the offset and read length. How do I get around this?

    Here's a chunk of code:

    const int BlockSize = 1610612736;//1.5 GB

    FileInfo finfo = new FileInfo(FileName);

    using(StreamReader sr = File.OpenText(FileName))

    {

    Stream s = sr.BaseStream;

    int offset = 0;

    int readto = BlockSize;

    for(double i = 0; i < finfo.Length / BlockSize; i++)

    {

    byte[] TempBlock = new byte[BlockSize];

    s.Read(TempBlock, offset, (int)readto);

    offset = readto;

    readto += BlockSize;

    FileDataBlocks.Add(TempBlock);

    }

    }

    submitted by /u/Communist_Cheeze
    [link] [comments]

    No comments:

    Post a Comment