Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

Name

DirectoryInfo

Synopsis

This class provides the same functionality as Directory, but in a strongly typed, object-oriented manner. An instance of this type represents a single directory. This class extends FileSystemInfo and implements all its methods. In addition, it adds Parent and Root properties to return the parent and root directories, respectively. Similarly, it also supplies GetDirectories( ) and GetFiles( ), to retrieve its subdirectories and files, as well as GetFileSystemInfos( ), which returns both the files and subdirectories contained by the current directory. MoveTo( ) allows you to move a directory from one place to another.

Given the similarity between this type and the Directory type, it may not be clear when one should be used in place of the other. The key difference is the Directory class is a collection of static utility functions, whereas a DirectoryInfo object is an actual object, maintaining state and identity in the classic style of all objects. (In fact, the DirectoryInfo methods often map over to use the corresponding Directory methods.)

public sealed class DirectoryInfo : FileSystemInfo {
// Public Constructors
   public DirectoryInfo(string path);
// Public Instance Properties
   public override bool Exists{get; }    
// overrides FileSystemInfo
   public override string Name{get; }    
// overrides FileSystemInfo
   public DirectoryInfo Parent{get; }
   public DirectoryInfo Root{get; }
// Public Instance Methods
   public void Create( );
   public DirectoryInfo CreateSubdirectory ...
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# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata