Q:

Is there a limit on the maximum number of files that can be opened in C#?

I am making an app and it needs to open at least 676 files simultaneously to a maximum of 1400 files. I will be writing to these files using the StreamWriter Class and reading the data using StreamReader Class. So, is there a maximum limit on the no of files that can be opened simultaneously for reading or writing in C# just like VC++ as described in the following link.
Is there a limit on number of open files in Windows. 

A:

The upper limit on files opened by .NET is governed by the limit imposed on the Win32 API CreateFile, which is 16384.

A:

This works for me:
  var streams = new Stream[10000];
  for (var i = 0; i < streams.Length; i++) {
    streams[i] = File.OpenWrite(Path.Combine(Path.GetTempFileName()));
    streams[i].WriteByte((byte)'A');
  }
  var tasks = new Task[streams.Length];
  for (var i = 0; i < streams.Length; i++) {
    var index = i;
    tasks[i] = new Task(() => {
      streams[index].WriteByte((byte)'B');
    });
    tasks[i].Start();
  }
  Task.WaitAll(tasks);
  for (var i = 0; i < streams.Length; i++) {
    streams[i].Close();
  }

