1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
using Microsoft.SharePoint.Client; ... static void Main(string[] args) { string kometDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); IniFile ini = new IniFile(kometDir + "\\komet.conf"); string cContext = ini.IniReadValue("common", "context", "http://localhost/man/doc/"); string domain = ini.IniReadValue("common", "domain", "sap.sd"); string user = ini.IniReadValue("common", "user", "wwwsapsd"); string passwd = ini.IniReadValue("common", "passwd", "12345678"); var context = new ClientContext("http://localhost/man/doc/"); context.Credentials = new NetworkCredential(user, passwd, domain); Uri filename = new Uri("http://localhost/man/doc/DocLib11/2016/Jan 2016/GKK 26.01.xlsx"); string serverrelative = filename.AbsolutePath; Microsoft.SharePoint.Client.File file = context.Web.GetFileByServerRelativeUrl(serverrelative); context.Load(file); ClientResult streamResult = file.OpenBinaryStream(); context.ExecuteQuery(); var fileName = @"C:\downloaded.xlsx"; var fileStream = System.IO.File.Create(fileName); streamResult.Value.CopyTo(fileStream); } |