DirectoryInfo

DirectoryInfo CF 1.0, serializable, marshal by reference

System.IO (mscorlib.dll) sealed class

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  (string   path   );    public override void  Delete  ( );  // overrides FileSystemInfo  public void  Delete  (bool   recursive   );    public DirectoryInfo[ ]  GetDirectories  ( );    public DirectoryInfo[ ]  GetDirectories  (string   searchPattern   );    public FileInfo[ ]  GetFiles  ( );    public FileInfo[ ]  GetFiles  (string   searchPattern   );    public FileSystemInfo[ ]  GetFileSystemInfos  ( );    public FileSystemInfo[ ]  GetFileSystemInfos  (string   searchPattern   );    public void  MoveTo  (string   destDirName   );    public override string  ToString  ( );  // overrides object  } 

Hierarchy

System.Object System.MarshalByRefObject FileSystemInfo(System.Runtime.Serialization.ISerializable) DirectoryInfo

Returned By

Directory.{CreateDirectory( ) , GetParent( )} , FileInfo.Directory



C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net