I need to use .NetFramework3.5 for my application, but CopyTo()
and WriteTo()
methods are not available in 3.5. what are the equivalent methods in 3.5?
when I run the code with 3.5 it is throwing the following error:
'System.IO.Stream' does not contain a definition for 'WriteTo' and no extension method 'WriteTo' accepting a first argument of type 'System.IO.Stream' could be found
Here is the code:
int fileId = 1;
foreach (string uri in uriList)
{
request = (HttpWebRequest)WebRequest.Create (baseURL + uri);
request.Headers.Add ("X", authenticateStr);
request.Accept = "application/pdf";
request.Method = "GET";
webResponse = (HttpWebResponse)request.GetResponse();
using (MemoryStream ms = new MemoryStream())
using (FileStream outfile = new FileStream("document_", FileMode.Create)) {
webResponse.GetResponseStream().WriteTo(ms);
if (ms.Length > int.MaxValue) {
throw new NotSupportedException("Cannot write a file larger than 2GB.");
}
outfile.Write(ms.GetBuffer(), 0, (int)ms.Length);
}
}
Console.WriteLine("Done!");