System.IO.FileStreamHelpers.CreateFileStream C# (CSharp) Méthode

CreateFileStream() public static méthode

public static CreateFileStream ( string path, bool write, bool append ) : Stream
path string
write bool
append bool
Résultat Stream
        public static Stream CreateFileStream(string path, bool write, bool append)
        {
            if (s_fileOpen == null)
            {
                s_fileOpen = GetFileOpenFunction();
            }
            int filemode = !write ? FileMode_Open : append ? FileMode_Append : FileMode_Create;
            int fileaccess = write ? FileAccess_Write : FileAccess_Read;
            return s_fileOpen(path, filemode, fileaccess, FileShare_Read);
        }

Usage Example

Exemple #1
0
        public StreamWriter(string path, bool append, Encoding encoding, int bufferSize)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }
            if (path.Length == 0)
            {
                throw new ArgumentException(SR.Argument_EmptyPath);
            }
            if (bufferSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum);
            }

            Stream stream = FileStreamHelpers.CreateFileStream(path, write: true, append: append);

            Init(stream, encoding, bufferSize, shouldLeaveOpen: false);
        }