HttpWebRequest request;
HttpWebResponse response = null;
string stringURL = SharePointDocumentLibraryURL + "/" + strFileName;
request = (HttpWebRequest)WebRequest.Create(stringURL);
request.Credentials = new System.Net.NetworkCredential(UserName,Password,Domain);
request.Timeout = 1000000;
request.AllowWriteStreamBuffering = false;
response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
//Write to disk
strFileName = (en.Url).Substring((en.Url).LastIndexOf("/") + 1);
FileStream fs = new FileStream(@"C:\testing\" + strFileName, FileMode.Create);//Give the Location where the file should be stored
byte[] read = new byte[256];
int count = s.Read(read, 0, read.Length);
while (count > 0)
{
fs.Write(read, 0, count);
count = s.Read(read, 0, read.Length);
}
fs.Close();
s.Close();
response.Close();
0 Comments Received
Post a Comment