Exam 14: Files and Streams
When you copy data from a file on a storage device into RAM, what are you doing?
B
Hardcoding numbers (unnamed, literal constants) in code without explanation is a bad programming practice.What are these hardcoded numbers known as?
C
A program that reads from a sequential access data file creates a FileStream object, and then the FileStream object is passed to a StreamReader object's constructor.Once this has been done, the ReadLine() method can be used to retrieve one line at a time from the data file.Show the sequence of instructions that would create the FileStream and StreamReader needed to access a data file, and then read one line from the file.
A program that reads from a sequential access data file contains many similar components to one that writes to a file.For example, a FileStream object is created, as in a program that writes to a file.However, the access must be FileAccess.Read (or ReadWrite), as in the following statement:
FileStream inFile =
new FileStream(FILENAME, FileMode.Open, FileAccess.Read);
Then, as when data is being written, the FileStream object is passed to a StreamReader object's constructor, as in the following statement:
StreamReader reader = new StreamReader(inFile);
After the StreamReader has been defined, the ReadLine() method can be used to retrieve one line at a time from the data file.For example, the following statement gets one line of data from the file and stores it in a string named recordIn:
string recordIn = reader.ReadLine();
What is the process of converting objects into streams of bytes known as?
A data file is what type of file when each record is read in order of its position in the file?
If you attempt to open a file with the Open file mode, what happens if the file does not exist?
The FileStream class has 15 overloaded constructors.What can you tell about the FileStream object named myFile, given the constructor below?
FileStream myFile =
new FileStream("SomeText.txt", FileMode.Create,
FileAccess.Write);
What must be done in order to convert streams of bytes back into objects?
What are the disadvantages to writing data to a text file using tokens and delimiters as opposed to writing an entire object to a file at once?
Most computer users organize their files into directories, which are also known by what term?
When you produce screen output and accept keyboard input, you use the Console class, which provides access to which three standard streams?
When you perform an input operation in an application, the bytes flowing into your program from an input device typically are pictured by programmers as what?
Permanent storage that does not lose contents when a computer loses power is known as what type of storage?
What file mode is used to open an existing file, and empty the file once opened so that the file is zero bytes in size?
Due to the fact that data can be erased from files, what term do programmers generally prefer over permanent storage?
What term describes any one of the letters, numbers, or other special symbols (such as punctuation marks) that comprise data.
Sometimes it is necessary to process a sequential text file multiple times from the beginning during a program's execution.After the file is processed the first time, the file pointer is at the end of the file.How can you reread the file at this point?
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)