Firstly, I want to be clear that I do not mean the simultaneous transmission of the TCP / IP stream, I want to take the output of the C # stream and translate it to several purposes.
For example, if I had FileStream (fs) and MemoryStream (ms) and FtpStream (ftps) and something like
... SuperStreamWriter ss = new SuperStreamWriter(fs, ms, ftps); ss.Write(helloWorld, 0, helloWorld.length); } class SuperStreamWriter : Stream { Stream[] _s; public SuperStreamWriter(params Stream[] s) { _s = s; } public override void Write(byte[] buffer, int offset, int count) { foreach (Stream s in _s) { s.Write(buffer, offset, count); } }
Hello, the world will be crowded out to all three of my streams. Does anyone know anything that will give me similar functionality to what I am describing to others using this foreach loop in a buffer? Also, if the foreach loop is my only / best option, would it be safe to loop through each iteration of the foreach loop, as it is?
source share