I'm using SharePoint 2013 Foundation and I'm trying to download a file using the client object model.
Here is my code:
static void Main(string[] args){
ClientContext context = new ClientContext("http://servername");
FileInformation fInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(context, "/ParseBritsData/TestTimeSeries.xlsx");
System.IO.FileStream outPutFile = System.IO.File.OpenWrite("c:\\projects\\test.xlsx");
fInfo.Stream.CopyTo(outPutFile);
fInfo.Stream.Close();
outPutFile.Close();
}
The code runs without error, but test.xlsx has zero length. I checked and http://servername/ParseBritsData/TestTimeSeries.xlsx does exist.
I appear to be doing something wrong, but I'm not sure what. Any suggestions?
Thanks!
Brian
Brian Hochgurtel
My blog