Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Exception upload file size with Microsoft.SharePoint.Client

$
0
0

Hi,

I have a problem using Microsoft.SharePoint.Client... I've created a method to send a opened file to library in SharePoint 2013. I always have this problem. Can anybody help me?

Exception: The process cannot access the file 'c:\file.xlsx' because it is being used by another process.

        public void UploadDocument(string siteUrl, string documentLibraryName, string fileName)
        {
            ClientContext clientContext = new ClientContext(siteUrl);
            Web web = clientContext.Web;
            clientContext.Load(web);

            var fInfo = new FileInfo(fileName).Name;
            var targetLocation = string.Format("{0}/{1}/{2}", siteUrl, documentLibraryName, fInfo);

            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, targetLocation, fs, true);
            }
        }




Viewing all articles
Browse latest Browse all 11571

Trending Articles



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