All fields

“File I/O & Streams” in Information Technology

15 questions across 2 technologies.

Information Technology

15 questions in 2 technologies

#QuestionTechnologyTopicLevel
1How do you correctly implement async, cancellable file I/O using CancellationToken with FileStream operations? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
2How do you read and write an entire text file's contents using the simplest File class methods? C# › File I/O & StreamsC#File I/O & StreamsBeginner
3What is the difference between File.ReadAllLines() and File.ReadLines() in terms of memory usage? C# › File I/O & StreamsC#File I/O & StreamsBeginner
4How does the 'using' statement (or 'using' declaration) ensure a FileStream is properly closed, even if an exception occurs? C# › File I/O & StreamsC#File I/O & StreamsIntermediate
5How do StreamReader and StreamWriter differ from directly using a FileStream, and when would you choose them? C# › File I/O & StreamsC#File I/O & StreamsIntermediate
6How do you efficiently copy data between two streams using Stream.CopyToAsync(), and why is this preferred over a manual byte-by-byte loop? C# › File I/O & StreamsC#File I/O & StreamsIntermediate
7How do you use FileSystemWatcher to monitor a directory for file changes, and what are its common reliability pitfalls? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
8How would you implement memory-mapped file access using MemoryMappedFile for efficient random access to a very large file? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
9How would you implement a robust, atomic file-write operation that avoids leaving a corrupted or partially-written file if the process crashes mid-write? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
10How would you implement a custom Stream subclass to wrap another stream with additional behavior, like counting bytes read? C# › File I/O & StreamsC#File I/O & StreamsAdvanced
11How do you read a file with ifstream and write with ofstream? C++ › I/O StreamsC++I/O StreamsIntermediate
12What does the finally block guarantee, and when is it commonly used? C# › Exception HandlingC#Exception HandlingBeginner
13How does an iterator method interact with try/finally, and when does the finally block actually execute given the method's lazy, on-demand nature? C# › Iterators & yield returnC#Iterators & yield returnIntermediate
14How does the IDisposable pattern and the 'using' statement help manage UNMANAGED resources that the garbage collector doesn't automatically clean up? C# › Memory & Garbage CollectionC#Memory & Garbage CollectionIntermediate
15How would you write a custom iterator that safely handles resource cleanup for a lazily-enumerated database cursor, ensuring the connection is closed even if enumeration is abandoned early? C# › Iterators & yield returnC#Iterators & yield returnAdvanced