PrepAway - Latest Free Exam Questions & Answers

How should you complete the relevant code?

DRAG DROP
You are creating a method that will split a single input file into two smaller output files.
The method must perform the following actions:
Create a file named header.dat that contains the first 20 bytes of the input file.
Create a file named body.dat that contains the remainder of the input file.
You need to create the method.
How should you complete the relevant code? (To answer, drag the appropriate code segments to
the correct locations in the answer are
a. Each code segment may be used once, more than once, or not at all. You may need to drag the
split bar between panes or scroll to view content.)

PrepAway - Latest Free Exam Questions & Answers

Answer:

4 Comments on “How should you complete the relevant code?

      1. Davis says:

        Nope.

        I think the code in the question is wrong.
        Because, those header and body are two separate streams. so it has to be read from the position zero.

        It should be corrected as below.
        fsSource.Read(body,20,body.length)

        But the answers are the ones given.

        #OpenForSuggestions




        1



        1
        1. Mike says:

          The answer is correct. It is
          fsSource.Read(body, 0, body.Length);
          The offset has to be 0 because with
          fsSource.Read(header, 0, header.Length);
          we already advanced the pointer of the fsSource to 20. As we do not reset that pointer we continue and get only the rest from position 20 on.




          3



          0

Leave a Reply