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);
}
}