title: Error "FileStream was asked to open a device that was not a file. For support for devices like 'com1:' ..." in windows 2016
body: <p>We have an application which has been running properly for years in windows 2008 with .NET 4.0. We recently switched to .NET 4.6 and windows 2016 and we are getting several errors as the following :</p>
  
  <pre><code>FileStream was asked to open a device that was not a file. For support for devices like 'com1:' or 'lpt1:', call CreateFile, then use the FileStream constructors that take an OS handle as an IntPtr.
  </code></pre>
  
  <p>This error is reported fairly frequently when the application writes a file in a folder which is shared with other systems.</p>
  
  <p>I investigate the problem and I'm quite sure that the problem <strong>does not</strong> depend on the file name, nor the file location. The code which writes the file  is straightforward :</p>
  
  <pre><code>  using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
    {
         fileStream.Write(myData, 0, myData.Count());
         fileStream.Close();
    }
  </code></pre>
  
  <p>If anyone can provide help or suggestion is appreciate. I extensively searched with google and I see only references which suggest that the problem is caused by a filename which is not valid, I'm quite sure this is not the problem here.</p>