Monday, May 21, 2012

How to programmatically download file from sharepoint

  Here i will show how to get the documents from share point site.For this we can use path of document to download or to do any file operation in folder.The below example has the path of the url of document(testfilename) i:e".If you  what to get the data we should use the web client class.For this we have to add the System.Net.Web Client name space
WebClient webc = new WebClient();
webc.UseDefaultCredentials = true;
byte[] testbytedata = webc.DownloadData(path);
FileStream fst = new FileStream(testfilename, FileMode.Create, FileAccess.ReadWrite);
BinaryWriter biw = new BinaryWriter(fst);

No comments: