The flashcards below were created by user iranye on FreezingBlue Flashcards.

  1. [C# 4.0 in a Nutshell, pg 539]
    What is the stream hierarchy in C Sharp?
    Image Upload
    • Backing store streams provide the raw data
    • Decorator streams provide transparent binary transformations (e.g., encryption)
    • Adapters offer methods for dealig in higher-level types such as strings and XML.
  2. [C# 4.0 in a Nutshell, pg 540]
    Using the following file stream object, create an array of bytes and save them to the file, then read them back.
    using (var s = new FileStream("test.txt",
    • s.WriteByte(101);
    • byte[] block = { 1, 2, 3, 4, 5 };
    • s.Write(block, 0, block.Length);
    • Console.WriteLine("s.Position: {0}", s.Position);
    • s.Position = 0;
    • s.Read(block, 0, block.Length);
  3. [C# 4.0 in a Nutshell, pg 542]
    In the context of a FileStream, what does the flush method do?
    Forces any internally buffered data to be written immediately. Flush is called when the stream is closed.
  4. [C# 4.0 in a Nutshell, pg 545]
    Using the diagram, which FileMode would you use to append to an existing file?
    Image Upload
  5. [C# 4.0 in a Nutshell, pg 546]
    Is it possible for more than one user or process to simultaneously read and write to the same file?
    • Yes, the FileStream class has the two methods:
    • public virtual void Lock(long position, long length)
    • public virtual void Unlock(long position, long length)
  6. [C# 4.0 in a Nutshell, pg 547]
    Introduced in Framework 3.5, what are the two kind of pipes of a PipeStream?
    • Anonymous pipes for one-way communication between a parent and child process on the same computer.id
    • Named pipes for two-way communication between two processes or computers on a Windows network.
  7. [C# 4.0 in a Nutshell, pg 547]
    Using the following code that sends a byte across a stream, write the corresponding Client that sends another byte back across.
    using (var s = new NamedPipeServerStream("pipedream")){
    Console.WriteLine("{0}data received: {1}", Environment.NewLine, s.ReadByte());}
    • using (var s = new NamedPipeClientStream("pipedream")){
    • s.Connect();
    • Console.WriteLine(s.ReadByte());
    • s.WriteByte(200);}
  8. [C# 4.0 in a Nutshell, pg 549]
    Using the PipeStream example, what mechanism could be used for messages longer than one byte?
    Using the message transmission mode, a party calling Read can know when the message is complete by checking the IsMessageComplete property.
Card Set:
2011-08-19 18:30:58
Sharp Stream IO FileStream XmlReader XML Bytes

Chapter 14 of C# 4.0 in a Nutshell
Show Answers: