别人共享一个sharepoint的文件夹给我,我想用代码控制,怎么连接?

yingang11 2020-05-28 05:18:44
别人共享一个sharepoint的文件夹给我,我希望通过c#代码操作这个文件夹,例如:新建子目录,上传文件等
但是不清楚该怎么连接这个文件夹,地址类似这种:
https://zfhk.sharepoint.com/:f:/s/JIM-ExCom2/EhFbuaoeYWJLk8NH4NvKGl4BuTFGNRuaR1BnOQitYSqOEA?email=xxxx%40xxxxuuuu.com&e=dZvO6E

...全文
181992 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
霖雨 版主 2021-03-09
  • 打赏
  • 举报
回复
上面的代码很靠谱
「已注销」 2020-08-06
  • 打赏
  • 举报
回复
可以使用 COMS API 操作,楼上的Code应该就可以
mslearn-nashma 2020-06-06
  • 打赏
  • 举报
回复
private static void UploadFileToSharePoint(string SiteUrl, string DocLibrary, string ClientSubFolder, string FileName, string Login, string Password) { try { #region ConnectToSharePoint var securePassword = new SecureString(); foreach (char c in Password) { securePassword.AppendChar(c); } var onlineCredentials = new SP.SharePointOnlineCredentials(Login, securePassword); #endregion #region Insert the data using (SP.ClientContext CContext = new SP.ClientContext(SiteUrl)) { CContext.Credentials = onlineCredentials; SP.Web web = CContext.Web; SP.FileCreationInformation newFile = new SP.FileCreationInformation(); byte[] FileContent = System.IO.File.ReadAllBytes(FileName); newFile.ContentStream = new MemoryStream(FileContent); newFile.Url = Path.GetFileName(FileName); SP.List DocumentLibrary = web.Lists.GetByTitle(DocLibrary); //SP.Folder folder = DocumentLibrary.RootFolder.Folders.GetByUrl(ClientSubFolder); SP.Folder Clientfolder = DocumentLibrary.RootFolder.Folders.Add(ClientSubFolder); Clientfolder.Update(); SP.File uploadFile = Clientfolder.Files.Add(newFile); CContext.Load(DocumentLibrary); CContext.Load(uploadFile); CContext.ExecuteQuery(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("The File has been uploaded"+Environment.NewLine+"FileUrl -->"+SiteUrl+"/"+DocLibrary+"/"+ClientSubFolder+"/" +Path.GetFileName(FileName)); } #endregion } catch (Exception exp) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(exp.Message + Environment.NewLine + exp.StackTrace); } finally { Console.ReadLine(); } }
mslearn-nashma 2020-06-06
  • 打赏
  • 举报
回复
static void Main(string[] args) { string SiteUrl = "https://You.sharepoint.com/sites/Upload"; string DocumentLibrary = "UploadLibrary"; string FileName = @"C:\testupload.pdf"; string CustomerFolder = "1564_dsfgsst"; string UserName = "samir.daoudi@******.co.uk"; string Password = "*****"; UploadFileToSharePoint(SiteUrl, DocumentLibrary, CustomerFolder, FileName, UserName, Password); }
Justin-Liu 2020-06-02
  • 打赏
  • 举报
回复
你试试把这个文件夹用onedrive for business同步到本地,然后进行操作,网络畅通的话应该会自动同步

3,242

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧