我目前正在尝试从WCF下载音频曲目,我需要一些帮助将其写入硬盘,如何配置streamwriter或其他在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
???
答案 0 :(得分:29)
Stream stream = MyService.Download(("1231"));
using (Stream s = File.Create(path))
{
stream.CopyTo(s);
}