using System; namespace Vanara.PInvoke; /// /// File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via /// various file I/O APIs. /// [Flags] [PInvokeData("winnt.h")] public enum FileFlagsAndAttributes : uint { /// /// A file that is read-only. Applications can read the file, but cannot write to it or delete it. This attribute is not honored on /// directories. For more information, see You cannot view or change the Read-only or the System attributes of folders in Windows Server /// 2003, in Windows XP, in Windows Vista or in Windows 7. /// FILE_ATTRIBUTE_READONLY = 0x00000001, /// The file or directory is hidden. It is not included in an ordinary directory listing. FILE_ATTRIBUTE_HIDDEN = 0x00000002, /// A file or directory that the operating system uses a part of, or uses exclusively. FILE_ATTRIBUTE_SYSTEM = 0x00000004, /// The handle that identifies a directory. FILE_ATTRIBUTE_DIRECTORY = 0x00000010, /// /// A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or /// removal . /// FILE_ATTRIBUTE_ARCHIVE = 0x00000020, /// This value is reserved for system use. FILE_ATTRIBUTE_DEVICE = 0x00000040, /// A file that does not have other attributes set. This attribute is valid only when used alone. FILE_ATTRIBUTE_NORMAL = 0x00000080, /// /// A file that is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is /// available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can /// entirely avoid writing the data. Otherwise, the data is written after the handle is closed. /// FILE_ATTRIBUTE_TEMPORARY = 0x00000100, /// A file that is a sparse file. FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200, /// A file or directory that has an associated reparse point, or a file that is a symbolic link. FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400, /// /// A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the /// default for newly created files and subdirectories. /// FILE_ATTRIBUTE_COMPRESSED = 0x00000800, /// /// The data of a file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. /// This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily /// change this attribute. /// FILE_ATTRIBUTE_OFFLINE = 0x00001000, /// The file or directory is not to be indexed by the content indexing service. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000, /// /// A file or directory that is encrypted. For a file, all data streams in the file are encrypted. For a directory, encryption is the /// default for newly created files and subdirectories. /// FILE_ATTRIBUTE_ENCRYPTED = 0x00004000, /// /// The directory or user data stream is configured with integrity (only supported on ReFS volumes). It is not included in an ordinary /// directory listing. The integrity setting persists with the file if it's renamed. If a file is copied the destination file will have /// integrity set if either the source file or destination directory have integrity set. /// /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This flag is not /// supported until Windows Server 2012. /// /// FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000, /// This value is reserved for system use. FILE_ATTRIBUTE_VIRTUAL = 0x00010000, /// /// The user data stream not to be read by the background data integrity scanner (AKA scrubber). When set on a directory it only provides /// inheritance. This flag is only supported on Storage Spaces and ReFS volumes. It is not included in an ordinary directory listing. /// /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This flag is not /// supported until Windows 8 and Windows Server 2012. /// /// FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000, /// FILE_ATTRIBUTE_EA = 0x00040000, /// Used to prevent the file from being purged from local storage when running low on disk space. FILE_ATTRIBUTE_PINNED = 0x00080000, /// Indicate that the file is not stored locally. FILE_ATTRIBUTE_UNPINNED = 0x00100000, /// /// This attribute only appears in directory enumeration classes (FILE_DIRECTORY_INFORMATION, FILE_BOTH_DIR_INFORMATION, etc.). When this /// attribute is set, it means that the file or directory has no physical representation on the local system; the item is virtual. /// Opening the item will be more expensive than normal, e.g. it will cause at least some of it to be fetched from a remote store. /// FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000, /// /// When this attribute is set, it means that the file or directory is not fully present locally. For a file that means that not all of /// its data is on local storage (e.g. it may be sparse with some data still in remote storage). For a directory it means that some of /// the directory contents are being virtualized from another location. Reading the file / enumerating the directory will be more /// expensive than normal, e.g. it will cause at least some of the file/directory content to be fetched from a remote store. Only /// kernel-mode callers can set this bit. /// FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000, /// FILE_ATTRIBUTE_STRICTLY_SEQUENTIAL = 0x20000000, /// /// Write operations will not go through any intermediate cache, they will go directly to disk. /// For additional information, see the Caching Behavior section of this topic. /// FILE_FLAG_WRITE_THROUGH = 0x80000000, /// /// The file or device is being opened or created for asynchronous I/O. /// /// When subsequent I/O operations are completed on this handle, the event specified in the OVERLAPPED structure will be set to the /// signaled state. /// /// If this flag is specified, the file can be used for simultaneous read and write operations. /// /// If this flag is not specified, then I/O operations are serialized, even if the calls to the read and write functions specify an /// OVERLAPPED structure. /// /// /// For information about considerations when using a file handle created with this flag, see the Synchronous and Asynchronous I/O /// Handles section of this topic. /// /// FILE_FLAG_OVERLAPPED = 0x40000000, /// /// The file or device is being opened with no system caching for data reads and writes. This flag does not affect hard disk caching or /// memory mapped files. /// /// There are strict requirements for successfully working with files opened with CreateFile using the FILE_FLAG_NO_BUFFERING flag, for /// details see File Buffering. /// /// FILE_FLAG_NO_BUFFERING = 0x20000000, /// /// Access is intended to be random. The system can use this as a hint to optimize file caching. /// This flag has no effect if the file system does not support cached I/O and FILE_FLAG_NO_BUFFERING. /// For more information, see the Caching Behavior section of this topic. /// FILE_FLAG_RANDOM_ACCESS = 0x10000000, /// /// Access is intended to be sequential from beginning to end. The system can use this as a hint to optimize file caching. /// This flag should not be used if read-behind (that is, reverse scans) will be used. /// This flag has no effect if the file system does not support cached I/O and FILE_FLAG_NO_BUFFERING. /// For more information, see the Caching Behavior section of this topic. /// FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000, /// /// The file is to be deleted immediately after all of its handles are closed, which includes the specified handle and any other open or /// duplicated handles. /// If there are existing open handles to a file, the call fails unless they were all opened with the FILE_SHARE_DELETE share mode. /// Subsequent open requests for the file fail, unless the FILE_SHARE_DELETE share mode is specified. /// FILE_FLAG_DELETE_ON_CLOSE = 0x04000000, /// /// The file is being opened or created for a backup or restore operation. The system ensures that the calling process overrides file /// security checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME privileges. For more information, see Changing Privileges in /// a Token. /// /// You must set this flag to obtain a handle to a directory. A directory handle can be passed to some functions instead of a file /// handle. For more information, see the Remarks section. /// /// FILE_FLAG_BACKUP_SEMANTICS = 0x02000000, /// /// Access will occur according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file /// systems that support that naming. Use care when using this option, because files created with this flag may not be accessible by /// applications that are written for MS-DOS or 16-bit Windows. /// FILE_FLAG_POSIX_SEMANTICS = 0x01000000, /// /// The file or device is being opened with session awareness. If this flag is not specified, then per-session devices (such as a device /// using RemoteFX USB Redirection) cannot be opened by processes running in session 0. This flag has no effect for callers not in /// session 0. This flag is supported only on server editions of Windows. /// Windows Server 2008 R2 and Windows Server 2008: This flag is not supported before Windows Server 2012. /// FILE_FLAG_SESSION_AWARE = 0x00800000, /// /// Normal reparse point processing will not occur; CreateFile will attempt to open the reparse point. When a file is opened, a file /// handle is returned, whether or not the filter that controls the reparse point is operational. /// This flag cannot be used with the CREATE_ALWAYS flag. /// If the file is not a reparse point, then this flag is ignored. /// FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000, /// /// The file data is requested, but it should continue to be located in remote storage. It should not be transported back to local /// storage. This flag is for use by remote storage systems. /// FILE_FLAG_OPEN_NO_RECALL = 0x00100000, /// /// If you attempt to create multiple instances of a pipe with this flag, creation of the first instance succeeds, but creation of the /// next instance fails with ERROR_ACCESS_DENIED. /// FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000, /// Impersonates a client at the Anonymous impersonation level. SECURITY_ANONYMOUS = 0x00000000, /// Impersonates a client at the Identification impersonation level. SECURITY_IDENTIFICATION = 0x00010000, /// /// Impersonate a client at the impersonation level. This is the default behavior if no other flags are specified along with the /// SECURITY_SQOS_PRESENT flag. /// SECURITY_IMPERSONATION = 0x00020000, /// Impersonates a client at the Delegation impersonation level. SECURITY_DELEGATION = 0x00030000, /// The security tracking mode is dynamic. If this flag is not specified, the security tracking mode is static. SECURITY_CONTEXT_TRACKING = 0x00040000, /// /// Only the enabled aspects of the client's security context are available to the server. If you do not specify this flag, all aspects /// of the client's security context are available. /// This allows the client to limit the groups and privileges that a server can use while impersonating the client. /// SECURITY_EFFECTIVE_ONLY = 0x00080000, /// Include to enable the other SECURITY_ flags. SECURITY_SQOS_PRESENT = 0x00100000, /// The specified volume is a compressed volume. FILE_VOLUME_IS_COMPRESSED = 0x00008000, /// The specified volume supports object identifiers. FILE_SUPPORTS_OBJECT_IDS = 0x00010000, /// The specified volume supports the Encrypted File System (EFS). For more information, see File Encryption. FILE_SUPPORTS_ENCRYPTION = 0x00020000, /// The specified volume supports named streams. FILE_NAMED_STREAMS = 0x00040000, /// The specified volume is read-only. FILE_READ_ONLY_VOLUME = 0x00080000, /// The specified volume supports a single sequential write. FILE_SEQUENTIAL_WRITE_ONCE = 0x00100000, /// The specified volume supports transactions. For more information, see About KTM. FILE_SUPPORTS_TRANSACTIONS = 0x00200000, /// /// The specified volume supports hard links. For more information, see Hard Links and Junctions. /// Windows Vista and Windows Server 2008: This value is not supported. /// FILE_SUPPORTS_HARD_LINKS = 0x00400000, /// /// The specified volume supports extended attributes. An extended attribute is a piece of application-specific metadata that an /// application can associate with a file and is not part of the file's data. /// Windows Vista and Windows Server 2008: This value is not supported. /// FILE_SUPPORTS_EXTENDED_ATTRIBUTES = 0x00800000, /// /// The file system supports open by FileID. For more information, see FILE_ID_BOTH_DIR_INFO. /// Windows Vista and Windows Server 2008: This value is not supported. /// FILE_SUPPORTS_OPEN_BY_FILE_ID = 0x01000000, /// /// The specified volume supports update sequence number (USN) journals. For more information, see Change Journal Records. /// Windows Vista and Windows Server 2008: This value is not supported. /// FILE_SUPPORTS_USN_JOURNAL = 0x02000000, /// The file system supports integrity streams. FILE_SUPPORTS_INTEGRITY_STREAMS = 0x04000000, /// /// The file system supports block cloning, that is, sharing logical clusters between files on the same volume. The file system /// reallocates on writes to shared clusters. /// FILE_SUPPORTS_BLOCK_REFCOUNTING = 0x08000000, /// /// The file system tracks whether each cluster of a file contains valid data (either from explicit file writes or automatic zeros) or /// invalid data (has not yet been written to or zeroed). File systems that use sparse valid data length (VDL) do not store a valid data /// length and do not require that valid data be contiguous within a file. /// FILE_SUPPORTS_SPARSE_VDL = 0x10000000, /// The specified volume is a direct access (DAX) volume. FILE_DAX_VOLUME = 0x20000000, /// The file system supports ghosting. FILE_SUPPORTS_GHOSTING = 0x40000000, } /// /// The requested sharing mode of the file or device, which can be read, write, both, delete, all of these, or none (refer to the following /// table). Access requests to attributes or extended attributes are not affected by this flag. /// [PInvokeData("winnt.h")] [Flags] public enum FILE_SHARE : uint { /// /// Enables subsequent open operations on a file or device to request read access. /// Otherwise, other processes cannot open the file or device if they request read access. /// If this flag is not specified, but the file or device has been opened for read access, the function fails. /// FILE_SHARE_READ = 0x00000001, /// /// Enables subsequent open operations on a file or device to request write access. /// Otherwise, other processes cannot open the file or device if they request write access. /// /// If this flag is not specified, but the file or device has been opened for write access or has a file mapping with write access, the /// function fails. /// /// FILE_SHARE_WRITE = 0x00000002, /// /// Enables subsequent open operations on a file or device to request delete access. /// Otherwise, other processes cannot open the file or device if they request delete access. /// If this flag is not specified, but the file or device has been opened for delete access, the function fails. /// Delete access allows both delete and rename operations. /// FILE_SHARE_DELETE = 0x00000004, }