📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

File System

Files, directories, paths, permissions, streams, buffers, file locks, and sequential versus random access in .NET on Windows and Linux.

  1. What actually is a file and a directory at the operating system level, and how do you list and walk directories efficiently in .NET?

    Files, directories, metadata, inodes and links, plus efficient directory enumeration in .NET with EnumerateFiles and EnumerationOptions.

    Junior Theory File System Β· πŸ”— 3 follow-ups
  2. How do you build and handle file paths so that a .NET application works on both Windows and Linux? Explain absolute vs relative paths, separators, Path.Combine vs Path.Join, and case sensitivity.

    Cross-platform path handling in .NET: separators, absolute vs relative paths, the current directory, Path.Combine vs Path.Join, case sensitivity and long paths.

    Intermediate Theory File System Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  3. Code review: this endpoint returns a file from the server based on a name in the query string. What is wrong with it, and how would you fix it? ```csharp app.MapGet("/download", (string file) => { var path = Path.Combine("/var/app/reports", file); return Results.File(path, "application/octet-stream"); }); ```

    Path traversal (directory traversal) in a file download endpoint, why Path.Combine does not protect you, and safe patterns including root checks, ID mapping and Zip Slip.

    Senior CodeReview File System Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  4. How do file permissions work on Linux and Windows? Your .NET app works locally but throws UnauthorizedAccessException when writing to a mounted folder in a container. How do you fix it properly?

    Unix permission bits, owners and groups, Windows ACLs, how .NET exposes them, and fixing permission errors for non-root containers with mounted volumes.

    Mid-Level Debugging File System Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  5. What is a Stream in .NET? Explain how FileStream, MemoryStream and wrapper streams like GZipStream fit together, and the common mistakes when reading from a stream.

    The Stream abstraction, backing vs decorator streams, Read semantics, Position and CanSeek, disposal chains, async I/O and when to use StreamReader or Pipelines.

    Mid-Level Theory File System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. Explain the layers of buffering between your .NET code and the disk. What does Flush actually guarantee, and how do you write a file so it survives a crash or power loss?

    Application, FileStream, OS page cache and device buffers; Flush vs Flush(true)/fsync; WriteThrough; atomic write-then-rename; ArrayPool for I/O buffers.

    Senior Theory File System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. "The process cannot access the file because it is being used by another process." How do file locks work on Windows and Linux, how does FileShare affect them, and how do you debug and fix this error?

    Share modes, mandatory vs advisory locking, byte-range locks, how .NET maps FileShare on each OS, finding the process holding a file, and safe cross-process coordination.

    Mid-Level Debugging File System Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. What is the difference between sequential and random file access? Why does it matter for performance on HDDs and SSDs, and which .NET APIs (FileOptions, RandomAccess, memory-mapped files) help with each?

    Sequential vs random I/O, device and OS effects (seek time, read-ahead, page cache), FileOptions hints, the RandomAccess API, and memory-mapped files.

    Senior Theory File System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. You need to import a 20 GB CSV file into SQL Server every night from a .NET service running in a container with a 1 GB memory limit. How would you design it?

    Designing a memory-bounded, resumable large-file import: streaming, low-allocation parsing, bounded pipelines, bulk insert, checkpoints and bad-row handling.

    Senior RealWorldScenario File System Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me