Home > Enterprise >  Sharing a sharepoint folder for me, I want to use the code control, how to connect?
Sharing a sharepoint folder for me, I want to use the code control, how to connect?

Time:09-16

Sharing a sharepoint folder for me, I hope that through the c # code operating this folder, for example: the new subdirectories, upload files, etc.
But don't know how to connect this folder, address like this:
https://zfhk.sharepoint.com/:f:/s/JIM-ExCom2/EhFbuaoeYWJLk8NH4NvKGl4BuTFGNRuaR1BnOQitYSqOEA? Email=xxxx%40xxxxuuuu.com & amp; E=dZvO6E

CodePudding user response:

You try to use this folder onedrive for synchronous to the local business, then, should be automatically synchronized network unimpeded

CodePudding user response:

The static void Main (string [] args)
{
String SiteUrl="https://You.sharepoint.com/sites/Upload";
String a DocumentLibrary="UploadLibrary";
The string FileName=@ "C: \ testupload PDF";
String CustomerFolder="1564 _dsfgsst";
String UserName="samir. Daoudi @ * * * * * *. Co. UK";
String Password="* * * * *";
UploadFileToSharePoint (SiteUrl, a DocumentLibrary CustomerFolder, FileName, UserName, Password);
}

CodePudding user response:

Private static void UploadFileToSharePoint (string SiteUrl, string DocLibrary, string ClientSubFolder, string FileName, string Login, string Password)
{
Try
{
# region ConnectToSharePoint

Var securePassword=new SecureString ();
The 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. The 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 a DocumentLibrary=web. Lists. GetByTitle (DocLibrary);
//SP. Folder Folder.=a DocumentLibrary RootFolder. Folders. GetByUrl (ClientSubFolder);
SP. Folder Clientfolder=a DocumentLibrary. RootFolder. Folders. The Add (ClientSubFolder);
Clientfolder. The Update ();
SP. The File uploadFile=Clientfolder. Files. The Add (newFile);

CContext. Load (a DocumentLibrary);
CContext. Load (uploadFile);
CContext. ExecuteQuery ();
The Console. ForegroundColor=ConsoleColor. Green;
Console. WriteLine (" The File has had uploaded "+ Environment. The NewLine +" FileUrl - & gt;" + DocLibrary SiteUrl + "/" + + "/" + ClientSubFolder + "/" + Path. The GetFileName (FileName));
}

# endregion
}
The catch (Exception exp)
{
The Console. ForegroundColor=ConsoleColor. Red;
Console. WriteLine (exp. Message + Environment. NewLine + exp. StackTrace);
}
The finally
{
Console.ReadLine();
}
}

CodePudding user response:

Can use COMS API operation, the Code should be ok for upstairs
  • Related