How can I download a binary file (like .doc or .pdf) from http to my
harddrive using the .net framework?
WebRequest objRequest = System.Net.Http WebRequest.Crea te(url);
objResponse = objRequest.GetR esponse();
BinaryReader bsRead = new BinaryReader(ob jResponse.GetRe sponseStream()
FileStream fs = new FileStream("tes t.doc", FileMode.Create New);
while(bsRead.Pe ekChar() != -1)
{
cbuf=bsRead.Rea dByte();
fs.WriteByte(cb uf);
}
is one of the method I've tried. All of them failed becuase seeing in
the base stream wasn't supported. All tutorals and examples i've seen,
both on the internet and in msdn, deals with reading text, or a binary
file of predefined size.
Downloading a .doc file using Webclient.Downl oadFile(...) resulted in
a file that seemed to have been treated like text, not binary.
Please help!
harddrive using the .net framework?
WebRequest objRequest = System.Net.Http WebRequest.Crea te(url);
objResponse = objRequest.GetR esponse();
BinaryReader bsRead = new BinaryReader(ob jResponse.GetRe sponseStream()
FileStream fs = new FileStream("tes t.doc", FileMode.Create New);
while(bsRead.Pe ekChar() != -1)
{
cbuf=bsRead.Rea dByte();
fs.WriteByte(cb uf);
}
is one of the method I've tried. All of them failed becuase seeing in
the base stream wasn't supported. All tutorals and examples i've seen,
both on the internet and in msdn, deals with reading text, or a binary
file of predefined size.
Downloading a .doc file using Webclient.Downl oadFile(...) resulted in
a file that seemed to have been treated like text, not binary.
Please help!
Comment