Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Downloading a file with the Client Object Model Results in Zero Length File

$
0
0

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


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>