File

FileCF 1.0, ECMA 1.0

System.IO (mscorlib.dll)sealed class

Like the Directory type, this type offers a collection of static utility methods for working with files on the filesystem. In most cases, these methods are simply shortcuts for working with the System.IO types directly; for example, the AppendText( ) method returns a StreamWriter that can append text to the file specified in the path argument. This could be accomplished just as easily by creating a StreamWriter around a FileStream opened to the same file, with the FileMode.Append flag passed into the constructor.

That stated, there are methods on this type that aren't available through the Stream-based API. For example, the file's creation time, last-accessed time, last-modified times, and attributes are all available via this type, whereas no such corresponding call exists on the Stream type.

public sealed class File {
// Public Static Methods
   public static StreamWriter AppendText(string path);
   public static void Copy(string sourceFileName, string destFileName);
   public static void Copy(string sourceFileName, string destFileName, bool overwrite);
   public static FileStream Create(string path);
   public static FileStream Create(string path, int bufferSize);
   public static StreamWriter CreateText(string path);
   public static void Delete(string path);
   public static bool Exists(string path);
   public static FileAttributes GetAttributes(string path);
   public static DateTime GetCreationTime(string path);
   public static DateTime GetCreationTimeUtc(string path);
   public static DateTime GetLastAccessTime(string path);
   public static DateTime GetLastAccessTimeUtc(string path);
   public static DateTime GetLastWriteTime(string path);
   public static DateTime GetLastWriteTimeUtc(string path);
   public static void Move(string sourceFileName, string destFileName);
   public static FileStream Open(string path, FileMode mode);
   public static FileStream Open(string path, FileMode mode, FileAccess access);
   public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share);
   public static FileStream OpenRead(string path);
   public static StreamReader OpenText(string path);
   public static FileStream OpenWrite(string path);
   public static void SetAttributes(string path, FileAttributes fileAttributes);
   public static void SetCreationTime(string path, DateTime creationTime);
   public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
   public static void SetLastAccessTime(string path, DateTime lastAccessTime);
   public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
   public static void SetLastWriteTime(string path, DateTime lastWriteTime);
   public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
}


    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference
    Chapter 26. System
     
    ASPTreeView.com
     
    Evaluation has ¶СОexpired.
    Info...