Skip to Content
C# Cookbook
book

C# Cookbook

by Stephen Teilhet, Jay Hilyard
January 2004
Beginner to intermediate
864 pages
22h 18m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook

Chapter 11. Filesystem I/O

This chapter deals with the filesystem in four distinct ways. The first set of recipes looks at typical file interactions like creation, reading and writing, deletion, attributes, encoding methods for character data, and how to select the correct way (based on usage) to access files via streams. The second set looks at directory- or folder-based programming tasks like file creation as well as renaming, deleting, and determining attributes. The third set deals with the parsing of paths and the use of temporary files and paths, and the fourth set deals with more advanced topics in filesystem I/O, like asynchronous reads and writes, monitoring for certain filesystem actions, version information in files, and using P/Invoke to perform file I/O.

The file interactions section comes first since it sets the stage for many of the recipes in the temporary file and advanced sections. This is foundational knowledge that will help you understand the other file I/O recipes and how to modify them for your purposes. The various file and directory I/O techniques are used throughout the more advanced examples to help show a couple of different ways to approach the problems you will encounter working with filesystem I/O.

Unless otherwise specified, you need the following using statements in any program that uses snippets or methods from this chapter:

using System;
using System.IO;

11.1. Creating, Copying, Moving, and Deleting a File

Problem

You need to create a new file, copy ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
ASP.NET Cookbook

ASP.NET Cookbook

Michael A Kittel, Geoffrey T. LeBlond

Publisher Resources

ISBN: 0596003390Supplemental ContentCatalog PageErrata