How can I create folder new folder and upload new folder in SharePoint Document Library using Graph API in C#?
I want to create a folder and also If I have one folder and in that folder I have 5 files. so I need to upload that folder with that all 5 files.
<code>using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using Microsoft.Graph.Sites.GetAllSites;
namespace UploadFiles;
public class GraphHandler
{
public GraphServiceClient GraphClient { get; set; }
public GraphHandler(string tenantId, string clientId, string clienSecret)
{
GraphClient = CreateGraphClient(tenantId, clientId, clienSecret);
}
public GraphServiceClient CreateGraphClient(string tenantId, string clientId, string clientSecret)
{
var option = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredentials = new ClientSecretCredential(tenantId, clientId, clientSecret, option);
var scope = new[] { "https://graph.microsoft.com/.default" };
return new GraphServiceClient(clientSecretCredentials, scope);
}
}
</code>
<code>using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using Microsoft.Graph.Sites.GetAllSites;
namespace UploadFiles;
public class GraphHandler
{
public GraphServiceClient GraphClient { get; set; }
public GraphHandler(string tenantId, string clientId, string clienSecret)
{
GraphClient = CreateGraphClient(tenantId, clientId, clienSecret);
}
public GraphServiceClient CreateGraphClient(string tenantId, string clientId, string clientSecret)
{
var option = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredentials = new ClientSecretCredential(tenantId, clientId, clientSecret, option);
var scope = new[] { "https://graph.microsoft.com/.default" };
return new GraphServiceClient(clientSecretCredentials, scope);
}
}
</code>
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;
using Microsoft.Graph.Sites.GetAllSites;
namespace UploadFiles;
public class GraphHandler
{
public GraphServiceClient GraphClient { get; set; }
public GraphHandler(string tenantId, string clientId, string clienSecret)
{
GraphClient = CreateGraphClient(tenantId, clientId, clienSecret);
}
public GraphServiceClient CreateGraphClient(string tenantId, string clientId, string clientSecret)
{
var option = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredentials = new ClientSecretCredential(tenantId, clientId, clientSecret, option);
var scope = new[] { "https://graph.microsoft.com/.default" };
return new GraphServiceClient(clientSecretCredentials, scope);
}
}
I am trying to using Graph handler that i mentioned above.
how can I do this?