summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/IO/FileMode.cs
blob: 3972cf0533bb2df2f44c62969c7a94508474167a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*============================================================
**
** Enum:   FileMode
** 
** 
**
**
** Purpose: Enum describing whether to create a new file or 
** open an existing one.
**
**
===========================================================*/
    
using System;

namespace System.IO {
    // Contains constants for specifying how the OS should open a file.
    // These will control whether you overwrite a file, open an existing
    // file, or some combination thereof.
    // 
    // To append to a file, use Append (which maps to OpenOrCreate then we seek
    // to the end of the file).  To truncate a file or create it if it doesn't 
    // exist, use Create.
    // 
    [Serializable]
    public enum FileMode
    {
        // Creates a new file. An exception is raised if the file already exists.
        CreateNew = 1,
    
        // Creates a new file. If the file already exists, it is overwritten.
        Create = 2,
    
        // Opens an existing file. An exception is raised if the file does not exist.
        Open = 3,
    
        // Opens the file if it exists. Otherwise, creates a new file.
        OpenOrCreate = 4,
    
        // Opens an existing file. Once opened, the file is truncated so that its
        // size is zero bytes. The calling process must open the file with at least
        // WRITE access. An exception is raised if the file does not exist.
        Truncate = 5,
        
        // Opens the file if it exists and seeks to the end.  Otherwise, 
        // creates a new file.
        Append = 6,
    }
}