title: c# - FileStream with FILE_FLAG_NO_BUFFRING , ReadAsync() can read any num of bytes that smaller than buffer
body: <p>I read this article about file buffering: <a href="https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering</a></p>
  <p>And I read the <a href="https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering?redirectedfrom=MSDN#alignment-and-file-access-requirements" rel="nofollow noreferrer">requirements for using <code>FILE_FLAG_NO_BUFFERING</code></a>.</p>
  <p>This is my code:</p>
  <pre><code>FileOptions nocash = (FileOptions)0x20000000;
  FileStream fs;
  byte[] data;
  
  public Form1()
  {
      InitializeComponent();
      fs = new FileStream(@&quot;C:\Users\iP\Documents\visual studio 2015\Projects\ConsoleApplication32\ConsoleApplication32\bin\Debug\hello.txt&quot;, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 8192, FileOptions.Asynchronous|nocash);
      data = new byte[5968];
  }
  
  private async void button1_Click(object sender, EventArgs e)
  {
      await fs.ReadAsync(data,0,5968);
      byte[] ff = new byte[6] { data[5942], data[2435], data[2313], data[213], data[343], data[3698], };
      string hh = Encoding.Default.GetString(ff);
      Text = hh;
  }
  </code></pre>
  <p>I read that:</p>
  <blockquote>
  <p>an application must meet certain requirements when working with files opened with FILE_FLAG_NO_BUFFERING. The following specifics apply:</p>
  <p>File access sizes, including the optional file offset in the OVERLAPPED structure, if specified, must be for a number of bytes that is an integer multiple of the volume sector size. For example, if the sector size is 512 bytes, an application can request reads and writes of 512, 1,024, 1,536, or 2,048 bytes, but not of 335, 981, or 7,171 bytes.</p>
  </blockquote>
  <p>But I noticed that I can read any numbers of bytes (if it is smaller than the internal buffer) .</p>
  <p>Can anyone explain this to me?</p>