The Labs \ Source Viewer \ SSCLI \ System.IO \ FileMode

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Enum:  FileMode
  18. **
  19. **
  20. ** Purpose: Enum describing whether to create a new file or
  21. ** open an existing one.
  22. **
  23. **
  24. ===========================================================*/
  25. using System;
  26. namespace System.IO
  27. {
  28.     // Contains constants for specifying how the OS should open a file.
  29.     // These will control whether you overwrite a file, open an existing
  30.     // file, or some combination thereof.
  31.     //
  32.     // To append to a file, use Append (which maps to OpenOrCreate then we seek
  33.     // to the end of the file). To truncate a file or create it if it doesn't
  34.     // exist, use Create.
  35.     //
  36.     [Serializable()]
  37.     [System.Runtime.InteropServices.ComVisible(true)]
  38.     public enum FileMode
  39.     {
  40.         // Creates a new file. An exception is raised if the file already exists.
  41.         CreateNew = 1,
  42.        
  43.         // Creates a new file. If the file already exists, it is overwritten.
  44.         Create = 2,
  45.        
  46.         // Opens an existing file. An exception is raised if the file does not exist.
  47.         Open = 3,
  48.        
  49.         // Opens the file if it exists. Otherwise, creates a new file.
  50.         OpenOrCreate = 4,
  51.        
  52.         // Opens an existing file. Once opened, the file is truncated so that its
  53.         // size is zero bytes. The calling process must open the file with at least
  54.         // WRITE access. An exception is raised if the file does not exist.
  55.         Truncate = 5,
  56.        
  57.         // Opens the file if it exists and seeks to the end. Otherwise,
  58.         // creates a new file.
  59.         Append = 6
  60.     }
  61. }

Developer Fusion