O'Reilly logo

C# 3.0 Cookbook, 3rd Edition by Stephen Teilhet, Jay Hilyard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Filesystem I/O

12.0. Introduction

This chapter deals with the file system 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.

  • Selecting the correct way (based on usage) to access files via streams.

The second set looks at directory-or folder-based programming tasks such as 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. The fourth set deals with more advanced topics in filesystem I/O, such as:

  • Asynchronous reads and writes.

  • Monitoring for certain file system actions.

  • Version information in files.

  • 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 fundamental 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 file system 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;

12.1. Manipulating File Attributes

Problem

You need to display or manipulate a file's attributes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required