Im currently trying to downlaod a audio track from a WCF, i need some help writing it to the harddisk, how do i configure streamwriter or other to do this in a webApp?
// Use Service to download stream (returns System.IO.Stream) Stream stream = MyService.Download(("1231")); // ReadStream StreamReader reader = new StreamReader(stream); reader.ReadToEnd(); // Write this stream to a file/Hard disk ???
C# StreamWriter The StreamWriter class in C# is used for writing characters to a stream. It uses the TextWriter class as a base class and provides the overload methods for writing data into a file. The StreamWriter is mainly used for writing multiple characters of data into a file.
C# StreamReader is used to read characters to a stream in a specified encoding. StreamReader. Read method reads the next character or next set of characters from the input stream. StreamReader is inherited from TextReader that provides methods to read a character, block, line, or all content.
StreamReader is designed for character input in a particular encoding, whereas the Stream class is designed for byte input and output. Use StreamReader for reading lines of information from a standard text file. Important. This type implements the IDisposable interface.
Stream stream = MyService.Download(("1231")); using (Stream s = File.Create(path)) { stream.CopyTo(s); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With