Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

Accessing alternative data-streams of files on an NTFS volume

Rate me:
Please Sign up or sign in to vote.
4.85/5 (53 votes)
15 Aug 2016CPOL4 min read 503.6K   5.4K   132  
A pair of classes to encapsulate access to NTFS alternative data streams.
<?xml version="1.0"?>
<doc>
    <assembly>
        <name>Trinet.Core.IO.Ntfs</name>
    </assembly>
    <members>
        <member name="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo">
            <summary>
            Represents the details of an alternative data stream.
            </summary>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.#ctor(System.String,Trinet.Core.IO.Ntfs.SafeNativeMethods.Win32StreamInfo)">
            <summary>
            Initializes a new instance of the <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> class.
            </summary>
            <param name="filePath">
            The full path of the file.
            This argument must not be <see langword="null"/>.
            </param>
            <param name="info">
            The <see cref="T:Trinet.Core.IO.Ntfs.SafeNativeMethods.Win32StreamInfo"/> containing the stream information.
            </param>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.#ctor(System.String,System.String,System.String,System.Boolean)">
            <summary>
            Initializes a new instance of the <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> class.
            </summary>
            <param name="filePath">
            The full path of the file.
            This argument must not be <see langword="null"/>.
            </param>
            <param name="streamName">
            The name of the stream
            This argument must not be <see langword="null"/>.
            </param>
            <param name="fullPath">
            The full path of the stream.
            If this argument is <see langword="null"/>, it will be generated from the 
            <paramref name="filePath"/> and <paramref name="streamName"/> arguments.
            </param>
            <param name="exists">
            <see langword="true"/> if the stream exists;
            otherwise, <see langword="false"/>.
            </param>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.FullPath">
            <summary>
            Returns the full path of this stream.
            </summary>
            <value>
            The full path of this stream.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.FilePath">
            <summary>
            Returns the full path of the file which contains the stream.
            </summary>
            <value>
            The full file-system path of the file which contains the stream.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Name">
            <summary>
            Returns the name of the stream.
            </summary>
            <value>
            The name of the stream.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Exists">
            <summary>
            Returns a flag indicating whether the specified stream exists.
            </summary>
            <value>
            <see langword="true"/> if the stream exists;
            otherwise, <see langword="false"/>.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Size">
            <summary>
            Returns the size of the stream, in bytes.
            </summary>
            <value>
            The size of the stream, in bytes.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.StreamType">
            <summary>
            Returns the type of data.
            </summary>
            <value>
            One of the <see cref="T:Trinet.Core.IO.Ntfs.FileStreamType"/> values.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Attributes">
            <summary>
            Returns attributes of the data stream.
            </summary>
            <value>
            A combination of <see cref="T:Trinet.Core.IO.Ntfs.FileStreamAttributes"/> values.
            </value>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.ToString">
            <summary>
            Returns a <see cref="T:System.String"/> that represents the current instance.
            </summary>
            <returns>
            A <see cref="T:System.String"/> that represents the current instance.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.GetHashCode">
            <summary>
            Serves as a hash function for a particular type.
            </summary>
            <returns>
            A hash code for the current <see cref="T:System.Object"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Equals(System.Object)">
            <summary>
            Indicates whether the current object is equal to another object of the same type.
            </summary>
            <param name="obj">
            An object to compare with this object.
            </param>
            <returns>
            <see langword="true"/> if the current object is equal to the <paramref name="obj"/> parameter;
            otherwise, <see langword="false"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Equals(Trinet.Core.IO.Ntfs.AlternateDataStreamInfo)">
            <summary>
            Returns a value indicating whether
            this instance is equal to another instance.
            </summary>
            <param name="other">
            The instance to compare to.
            </param>
            <returns>
            <see langword="true"/> if the current object is equal to the <paramref name="other"/> parameter;
            otherwise, <see langword="false"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.op_Equality(Trinet.Core.IO.Ntfs.AlternateDataStreamInfo,Trinet.Core.IO.Ntfs.AlternateDataStreamInfo)">
            <summary>
            The equality operator.
            </summary>
            <param name="first">
            The first object.
            </param>
            <param name="second">
            The second object.
            </param>
            <returns>
            <see langword="true"/> if the two objects are equal;
            otherwise, <see langword="false"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.op_Inequality(Trinet.Core.IO.Ntfs.AlternateDataStreamInfo,Trinet.Core.IO.Ntfs.AlternateDataStreamInfo)">
            <summary>
            The inequality operator.
            </summary>
            <param name="first">
            The first object.
            </param>
            <param name="second">
            The second object.
            </param>
            <returns>
            <see langword="true"/> if the two objects are not equal;
            otherwise, <see langword="false"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Delete">
            <summary>
            Deletes this stream from the parent file.
            </summary>
            <returns>
            <see langword="true"/> if the stream was deleted;
            otherwise, <see langword="false"/>.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.CalculateAccess(System.IO.FileMode,System.IO.FileAccess)">
            <summary>
            Calculates the access to demand.
            </summary>
            <param name="mode">
            The <see cref="T:System.IO.FileMode"/>.
            </param>
            <param name="access">
            The <see cref="T:System.IO.FileAccess"/>.
            </param>
            <returns>
            The <see cref="T:System.Security.Permissions.FileIOPermissionAccess"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Open(System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.Int32,System.Boolean)">
            <summary>
            Opens this alternate data stream.
            </summary>
            <param name="mode">
            A <see cref="T:System.IO.FileMode"/> value that specifies whether a stream is created if one does not exist, 
            and determines whether the contents of existing streams are retained or overwritten.
            </param>
            <param name="access">
            A <see cref="T:System.IO.FileAccess"/> value that specifies the operations that can be performed on the stream. 
            </param>
            <param name="share">
            A <see cref="T:System.IO.FileShare"/> value specifying the type of access other threads have to the file. 
            </param>
            <param name="bufferSize">
            The size of the buffer to use.
            </param>
            <param name="useAsync">
            <see langword="true"/> to enable async-IO;
            otherwise, <see langword="false"/>.
            </param>
            <returns>
            A <see cref="T:System.IO.FileStream"/> for this alternate data stream.
            </returns>
            <exception cref="T:System.ArgumentOutOfRangeException">
            <paramref name="bufferSize"/> is less than or equal to zero.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Open(System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.Int32)">
            <summary>
            Opens this alternate data stream.
            </summary>
            <param name="mode">
            A <see cref="T:System.IO.FileMode"/> value that specifies whether a stream is created if one does not exist, 
            and determines whether the contents of existing streams are retained or overwritten.
            </param>
            <param name="access">
            A <see cref="T:System.IO.FileAccess"/> value that specifies the operations that can be performed on the stream. 
            </param>
            <param name="share">
            A <see cref="T:System.IO.FileShare"/> value specifying the type of access other threads have to the file. 
            </param>
            <param name="bufferSize">
            The size of the buffer to use.
            </param>
            <returns>
            A <see cref="T:System.IO.FileStream"/> for this alternate data stream.
            </returns>
            <exception cref="T:System.ArgumentOutOfRangeException">
            <paramref name="bufferSize"/> is less than or equal to zero.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Open(System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)">
            <summary>
            Opens this alternate data stream.
            </summary>
            <param name="mode">
            A <see cref="T:System.IO.FileMode"/> value that specifies whether a stream is created if one does not exist, 
            and determines whether the contents of existing streams are retained or overwritten.
            </param>
            <param name="access">
            A <see cref="T:System.IO.FileAccess"/> value that specifies the operations that can be performed on the stream. 
            </param>
            <param name="share">
            A <see cref="T:System.IO.FileShare"/> value specifying the type of access other threads have to the file. 
            </param>
            <returns>
            A <see cref="T:System.IO.FileStream"/> for this alternate data stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Open(System.IO.FileMode,System.IO.FileAccess)">
            <summary>
            Opens this alternate data stream.
            </summary>
            <param name="mode">
            A <see cref="T:System.IO.FileMode"/> value that specifies whether a stream is created if one does not exist, 
            and determines whether the contents of existing streams are retained or overwritten.
            </param>
            <param name="access">
            A <see cref="T:System.IO.FileAccess"/> value that specifies the operations that can be performed on the stream. 
            </param>
            <returns>
            A <see cref="T:System.IO.FileStream"/> for this alternate data stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.Open(System.IO.FileMode)">
            <summary>
            Opens this alternate data stream.
            </summary>
            <param name="mode">
            A <see cref="T:System.IO.FileMode"/> value that specifies whether a stream is created if one does not exist, 
            and determines whether the contents of existing streams are retained or overwritten.
            </param>
            <returns>
            A <see cref="T:System.IO.FileStream"/> for this alternate data stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.OpenRead">
            <summary>
            Opens this stream for reading.
            </summary>
            <returns>
            A read-only <see cref="T:System.IO.FileStream"/> for this stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.OpenWrite">
            <summary>
            Opens this stream for writing.
            </summary>
            <returns>
            A write-only <see cref="T:System.IO.FileStream"/> for this stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo.OpenText">
            <summary>
            Opens this stream as a text file.
            </summary>
            <returns>
            A <see cref="T:System.IO.StreamReader"/> which can be used to read the contents of this stream.
            </returns>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
            <exception cref="T:System.ArgumentException">
            The path of the stream is invalid.
            </exception>
            <exception cref="T:System.ComponentModel.Win32Exception">
            There was an error opening the stream.
            </exception>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.FileStreamAttributes">
            <summary>
            Represents the attributes of a file stream.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamAttributes.None">
            <summary>
            No attributes.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamAttributes.ModifiedWhenRead">
            <summary>
            Set if the stream contains data that is modified when read.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamAttributes.ContainsSecurity">
            <summary>
            Set if the stream contains security data.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamAttributes.ContainsProperties">
            <summary>
            Set if the stream contains properties.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamAttributes.Sparse">
            <summary>
            Set if the stream is sparse.
            </summary>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.FileStreamType">
            <summary>
            Represents the type of data in a stream.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.Unknown">
            <summary>
            Unknown stream type.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.Data">
            <summary>
            Standard data.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.ExtendedAttributes">
            <summary>
            Extended attribute data.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.SecurityData">
            <summary>
            Security data.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.AlternateDataStream">
            <summary>
            Alternate data stream.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.Link">
            <summary>
            Hard link information.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.PropertyData">
            <summary>
            Property data.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.ObjectId">
            <summary>
            Object identifiers.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.ReparseData">
            <summary>
            Reparse points.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.SparseBlock">
            <summary>
            Sparse file.
            </summary>
        </member>
        <member name="F:Trinet.Core.IO.Ntfs.FileStreamType.TransactionData">
            <summary>
            Transactional data.
            (Undocumented - BACKUP_TXFS_DATA)
            </summary>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.FileSystem">
            <summary>
            File-system utilities.
            </summary>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.CreateInfo(System.String)">
            <summary>
            Creates a <see cref="T:System.IO.FileSystemInfo"/> for the specified path.
            </summary>
            <param name="path">
            The path of the file or directory.
            </param>
            <returns>
            The <see cref="T:System.IO.FileSystemInfo"/> representing the file or directory.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="path"/> is <see langword="null"/> or empty.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.ListAlternateDataStreams(System.IO.FileSystemInfo)">
            <summary>
            <span style="font-weight:bold;color:#a00;">(Extension Method)</span><br />
            Returns a read-only list of alternate data streams for the specified file.
            </summary>
            <param name="file">
            The <see cref="T:System.IO.FileSystemInfo"/> to inspect.
            </param>
            <returns>
            A read-only list of <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> objects
            representing the alternate data streams for the specified file, if any.
            If no streams are found, returns an empty list.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="file"/> is <see langword="null"/>.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="file"/> does not exist.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.ListAlternateDataStreams(System.String)">
            <summary>
            Returns a read-only list of alternate data streams for the specified file.
            </summary>
            <param name="filePath">
            The full path of the file to inspect.
            </param>
            <returns>
            A read-only list of <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> objects
            representing the alternate data streams for the specified file, if any.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="filePath"/> is <see langword="null"/> or an empty string.
            </exception>
            <exception cref="T:System.ArgumentException">
            <paramref name="filePath"/> is not a valid file path.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="filePath"/> does not exist.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.AlternateDataStreamExists(System.IO.FileSystemInfo,System.String)">
            <summary>
            <span style="font-weight:bold;color:#a00;">(Extension Method)</span><br />
            Returns a flag indicating whether the specified alternate data stream exists.
            </summary>
            <param name="file">
            The <see cref="T:System.IO.FileInfo"/> to inspect.
            </param>
            <param name="streamName">
            The name of the stream to find.
            </param>
            <returns>
            <see langword="true"/> if the specified stream exists;
            otherwise, <see langword="false"/>.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="file"/> is <see langword="null"/>.
            </exception>
            <exception cref="T:System.ArgumentException">
            <paramref name="streamName"/> contains invalid characters.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.AlternateDataStreamExists(System.String,System.String)">
            <summary>
            Returns a flag indicating whether the specified alternate data stream exists.
            </summary>
            <param name="filePath">
            The path of the file to inspect.
            </param>
            <param name="streamName">
            The name of the stream to find.
            </param>
            <returns>
            <see langword="true"/> if the specified stream exists;
            otherwise, <see langword="false"/>.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="filePath"/> is <see langword="null"/> or an empty string.
            </exception>
            <exception cref="T:System.ArgumentException">
            <para><paramref name="filePath"/> is not a valid file path.</para>
            <para>-or-</para>
            <para><paramref name="streamName"/> contains invalid characters.</para>
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.GetAlternateDataStream(System.IO.FileSystemInfo,System.String,System.IO.FileMode)">
            <summary>
            <span style="font-weight:bold;color:#a00;">(Extension Method)</span><br />
            Opens an alternate data stream.
            </summary>
            <param name="file">
            The <see cref="T:System.IO.FileInfo"/> which contains the stream.
            </param>
            <param name="streamName">
            The name of the stream to open.
            </param>
            <param name="mode">
            One of the <see cref="T:System.IO.FileMode"/> values, indicating how the stream is to be opened.
            </param>
            <returns>
            An <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> representing the stream.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="file"/> is <see langword="null"/>.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="file"/> was not found.
            </exception>
            <exception cref="T:System.ArgumentException">
            <paramref name="streamName"/> contains invalid characters.
            </exception>
            <exception cref="T:System.NotSupportedException">
            <paramref name="mode"/> is either <see cref="F:System.IO.FileMode.Truncate"/> or <see cref="F:System.IO.FileMode.Append"/>.
            </exception>
            <exception cref="T:System.IO.IOException">
            <para><paramref name="mode"/> is <see cref="F:System.IO.FileMode.Open"/>, and the stream doesn't exist.</para>
            <para>-or-</para>
            <para><paramref name="mode"/> is <see cref="F:System.IO.FileMode.CreateNew"/>, and the stream already exists.</para>
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.GetAlternateDataStream(System.IO.FileSystemInfo,System.String)">
            <summary>
            <span style="font-weight:bold;color:#a00;">(Extension Method)</span><br />
            Opens an alternate data stream.
            </summary>
            <param name="file">
            The <see cref="T:System.IO.FileInfo"/> which contains the stream.
            </param>
            <param name="streamName">
            The name of the stream to open.
            </param>
            <returns>
            An <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> representing the stream.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="file"/> is <see langword="null"/>.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="file"/> was not found.
            </exception>
            <exception cref="T:System.ArgumentException">
            <paramref name="streamName"/> contains invalid characters.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.GetAlternateDataStream(System.String,System.String,System.IO.FileMode)">
            <summary>
            Opens an alternate data stream.
            </summary>
            <param name="filePath">
            The path of the file which contains the stream.
            </param>
            <param name="streamName">
            The name of the stream to open.
            </param>
            <param name="mode">
            One of the <see cref="T:System.IO.FileMode"/> values, indicating how the stream is to be opened.
            </param>
            <returns>
            An <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> representing the stream.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="filePath"/> is <see langword="null"/> or an empty string.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="filePath"/> was not found.
            </exception>
            <exception cref="T:System.ArgumentException">
            <para><paramref name="filePath"/> is not a valid file path.</para>
            <para>-or-</para>
            <para><paramref name="streamName"/> contains invalid characters.</para>
            </exception>
            <exception cref="T:System.NotSupportedException">
            <paramref name="mode"/> is either <see cref="F:System.IO.FileMode.Truncate"/> or <see cref="F:System.IO.FileMode.Append"/>.
            </exception>
            <exception cref="T:System.IO.IOException">
            <para><paramref name="mode"/> is <see cref="F:System.IO.FileMode.Open"/>, and the stream doesn't exist.</para>
            <para>-or-</para>
            <para><paramref name="mode"/> is <see cref="F:System.IO.FileMode.CreateNew"/>, and the stream already exists.</para>
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.GetAlternateDataStream(System.String,System.String)">
            <summary>
            Opens an alternate data stream.
            </summary>
            <param name="filePath">
            The path of the file which contains the stream.
            </param>
            <param name="streamName">
            The name of the stream to open.
            </param>
            <returns>
            An <see cref="T:Trinet.Core.IO.Ntfs.AlternateDataStreamInfo"/> representing the stream.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="filePath"/> is <see langword="null"/> or an empty string.
            </exception>
            <exception cref="T:System.IO.FileNotFoundException">
            The specified <paramref name="filePath"/> was not found.
            </exception>
            <exception cref="T:System.ArgumentException">
            <para><paramref name="filePath"/> is not a valid file path.</para>
            <para>-or-</para>
            <para><paramref name="streamName"/> contains invalid characters.</para>
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.DeleteAlternateDataStream(System.IO.FileSystemInfo,System.String)">
            <summary>
            <span style="font-weight:bold;color:#a00;">(Extension Method)</span><br />
            Deletes the specified alternate data stream if it exists.
            </summary>
            <param name="file">
            The <see cref="T:System.IO.FileInfo"/> to inspect.
            </param>
            <param name="streamName">
            The name of the stream to delete.
            </param>
            <returns>
            <see langword="true"/> if the specified stream is deleted;
            otherwise, <see langword="false"/>.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="file"/> is <see langword="null"/>.
            </exception>
            <exception cref="T:System.ArgumentException">
            <paramref name="streamName"/> contains invalid characters.
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.FileSystem.DeleteAlternateDataStream(System.String,System.String)">
            <summary>
            Deletes the specified alternate data stream if it exists.
            </summary>
            <param name="filePath">
            The path of the file to inspect.
            </param>
            <param name="streamName">
            The name of the stream to find.
            </param>
            <returns>
            <see langword="true"/> if the specified stream is deleted;
            otherwise, <see langword="false"/>.
            </returns>
            <exception cref="T:System.ArgumentNullException">
            <paramref name="filePath"/> is <see langword="null"/> or an empty string.
            </exception>
            <exception cref="T:System.ArgumentException">
            <para><paramref name="filePath"/> is not a valid file path.</para>
            <para>-or-</para>
            <para><paramref name="streamName"/> contains invalid characters.</para>
            </exception>
            <exception cref="T:System.Security.SecurityException">
            The caller does not have the required permission. 
            </exception>
            <exception cref="T:System.UnauthorizedAccessException">
            The caller does not have the required permission, or the file is read-only.
            </exception>
            <exception cref="T:System.IO.IOException">
            The specified file is in use. 
            </exception>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle">
            <summary>
            A <see cref="T:System.Runtime.InteropServices.SafeHandle"/> for a global memory allocation.
            </summary>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.#ctor(System.IntPtr,System.Int32)">
            <summary>
            Initializes a new instance of the <see cref="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle"/> class.
            </summary>
            <param name="toManage">
            The initial handle value.
            </param>
            <param name="size">
            The size of this memory block, in bytes.
            </param>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.#ctor">
            <summary>
            Initializes a new instance of the <see cref="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle"/> class.
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.IsInvalid">
            <summary>
            Gets a value indicating whether the handle value is invalid.
            </summary>
            <value>
            <see langword="true"/> if the handle value is invalid;
            otherwise, <see langword="false"/>.
            </value>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.Size">
            <summary>
            Returns the size of this memory block.
            </summary>
            <value>
            The size of this memory block, in bytes.
            </value>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.Allocate(System.Int32)">
            <summary>
            Allocates memory from the unmanaged memory of the process using GlobalAlloc.
            </summary>
            <param name="bytes">
            The number of bytes in memory required.
            </param>
            <returns>
            A <see cref="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle"/> representing the memory.
            </returns>
            <exception cref="T:System.OutOfMemoryException">
            There is insufficient memory to satisfy the request.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.Invalid">
            <summary>
            Returns an invalid handle.
            </summary>
            <returns>
            An invalid <see cref="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle"/>.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.SafeHGlobalHandle.ReleaseHandle">
            <summary>
            Executes the code required to free the handle.
            </summary>
            <returns>
            <see langword="true"/> if the handle is released successfully;
            otherwise, in the event of a catastrophic failure, <see langword="false"/>.
            In this case, it generates a releaseHandleFailed MDA Managed Debugging Assistant.
            </returns>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.SafeNativeMethods">
            <summary>
            Safe native methods.
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.StreamName.MemoryBlock">
            <summary>
            Returns the handle to the block of memory.
            </summary>
            <value>
            The <see cref="T:Trinet.Core.IO.Ntfs.SafeHGlobalHandle"/> representing the block of memory.
            </value>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.StreamName.Dispose">
            <summary>
            Performs application-defined tasks associated with freeing, 
            releasing, or resetting unmanaged resources.
            </summary>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.StreamName.EnsureCapacity(System.Int32)">
            <summary>
            Ensures that there is sufficient memory allocated.
            </summary>
            <param name="capacity">
            The required capacity of the block, in bytes.
            </param>
            <exception cref="T:System.OutOfMemoryException">
            There is insufficient memory to satisfy the request.
            </exception>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.StreamName.ReadString(System.Int32)">
            <summary>
            Reads the Unicode string from the memory block.
            </summary>
            <param name="length">
            The length of the string to read, in characters.
            </param>
            <returns>
            The string read from the memory block.
            </returns>
        </member>
        <member name="M:Trinet.Core.IO.Ntfs.StreamName.ReadStreamName(System.Int32)">
            <summary>
            Reads the string, and extracts the stream name.
            </summary>
            <param name="length">
            The length of the string to read, in characters.
            </param>
            <returns>
            The stream name.
            </returns>
        </member>
        <member name="T:Trinet.Core.IO.Ntfs.Properties.Resources">
            <summary>
              A strongly-typed resource class, for looking up localized strings, etc.
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.ResourceManager">
            <summary>
              Returns the cached ResourceManager instance used by this class.
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Culture">
            <summary>
              Overrides the current thread's CurrentUICulture property for all
              resource lookups using this strongly typed resource class.
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_AccessDenied_Path">
            <summary>
              Looks up a localized string similar to Access to the path &apos;{0}&apos; was denied..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_AlreadyExists">
            <summary>
              Looks up a localized string similar to Cannot create &apos;{0}&apos; because a file or directory with the same name already exists..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_DirectoryNotFound">
            <summary>
              Looks up a localized string similar to Could not find a part of the path &apos;{0}&apos;..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_DriveNotFound">
            <summary>
              Looks up a localized string similar to Could not find the drive &apos;{0}&apos;. The drive might not be ready or might not be mapped..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_FileAlreadyExists">
            <summary>
              Looks up a localized string similar to The file &apos;{0}&apos; already exists..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_InvalidFileChars">
            <summary>
              Looks up a localized string similar to The specified stream name contains invalid characters..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_InvalidMode">
            <summary>
              Looks up a localized string similar to The specified mode &apos;{0}&apos; is not supported..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_NonFile">
            <summary>
              Looks up a localized string similar to The specified file name &apos;{0}&apos; is not a disk-based file..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_SharingViolation">
            <summary>
              Looks up a localized string similar to The process cannot access the file &apos;{0}&apos; because it is being used by another process..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_StreamExists">
            <summary>
              Looks up a localized string similar to The specified alternate data stream &apos;{0}&apos; already exists on file &apos;{1}&apos;..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_StreamNotFound">
            <summary>
              Looks up a localized string similar to The specified alternate data stream &apos;{0}&apos; does not exist on file &apos;{1}&apos;..
            </summary>
        </member>
        <member name="P:Trinet.Core.IO.Ntfs.Properties.Resources.Error_UnknownError">
            <summary>
              Looks up a localized string similar to Unknown error: {0}.
            </summary>
        </member>
    </members>
</doc>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer CodeProject
United Kingdom United Kingdom
I started writing code when I was 8, with my trusty ZX Spectrum and a subscription to "Input" magazine. Spent many a happy hour in the school's computer labs with the BBC Micros and our two DOS PCs.

After a brief detour into the world of Maths, I found my way back into programming during my degree via free copies of Delphi and Visual C++ given away with computing magazines.

I went straight from my degree into my first programming job, at Trinet Ltd. Eleven years later, the company merged to become ArcomIT. Three years after that, our project manager left to set up Nevalee Business Solutions, and took me with him. Since then, we've taken on four more members of staff, and more work than you can shake a stick at. Smile | :)

Between writing custom code to integrate with Visma Business, developing web portals to streamline operations for a large multi-national customer, and maintaining RedAtlas, our general aviation airport management system, there's certainly never a dull day in the office!

Outside of work, I enjoy real ale and decent books, and when I get the chance I "tinkle the ivories" on my Technics organ.

Comments and Discussions