nerdexam
Microsoft

98-372 · Question #36

Which of the following classes can directly interact with the file system? Each correct answer represents a complete solution. Choose all that apply.

The correct answer is B. FileStream D. StreamReader. The FileStream or StreamReader class can directly interact with the file system. The FileStream class is contained in the System.IO namespace. It inherits the Stream class. It specifies the write, read, and other file-related operations either in a synchronous or asynchronous man

Understanding Namespaces and Classes

Question

Which of the following classes can directly interact with the file system? Each correct answer represents a complete solution. Choose all that apply.

Options

  • ATextReader
  • BFileStream
  • CMemoryStream
  • DStreamReader

How the community answered

(33 responses)
  • A
    6% (2)
  • B
    85% (28)
  • C
    9% (3)

Explanation

The FileStream or StreamReader class can directly interact with the file system. The FileStream class is contained in the System.IO namespace. It inherits the Stream class. It specifies the write, read, and other file-related operations either in a synchronous or asynchronous manner. The Read and Write methods are used to perform synchronous read and write operations, respectively. Similarly, the BeginRead, BeginWrite, EndRead, and EndWrite methods are used to perform asynchronous read and write operations. The FileStream class supports random access to files by using the Seek method. It also buffers input and output files for enhancing The StreamReader class is derived from the System.IO namespace. It is implemented by the TextReader class. It reads lines of data from a byte stream stored in a text file in a particular encoding. By default, it supports UTF-8 encoding for character input. Answer: C is incorrect. The MemoryStream class is contained in the System.IO namespace. It inherits the Stream class. It reads and writes a stream of data in bytes to a memory instead of a disk. It stores data as an unsigned byte array, which is initialized when a MemoryStream object is created. An advantage of the MemoryStream class is that it saves data storage in buffers and Answer: A is incorrect. The TextReader class is used to provide a reader that can read a sequential chain of characters. It is the abstract base class of the StreamReader and StringReader classes. These derived classes can be used to open a text file for reading a specified range of characters, or to create a reader based on an existing stream. A derived class must at least implement the Peek and Read methods to make a functional instance of the TextReader class.

Topics

#FileStream#StreamReader#file system#IO classes

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice