System.IO.Tests.FileStream_Flush.FlushOnReadOnlyStreamDoesNotThrow C# (CSharp) Méthode

FlushOnReadOnlyStreamDoesNotThrow() private méthode

private FlushOnReadOnlyStreamDoesNotThrow ( bool flushToDisk ) : void
flushToDisk bool
Résultat void
        public void FlushOnReadOnlyStreamDoesNotThrow(bool? flushToDisk)
        {
            string fileName = GetTestFilePath();
            File.WriteAllBytes(fileName, new byte[] { 0 });
            File.SetAttributes(fileName, FileAttributes.ReadOnly);
            try
            {
                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                {
                    Flush(fs, flushToDisk);
                }
            }
            finally
            {
                File.SetAttributes(fileName, FileAttributes.Normal);
            }
        }