Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> List drive's root folder
List drive's root folder.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Files; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; GetDriveItemsResponse response = await client.GetDriveItems("/", new DriveId("b!T7ZW_FMzJ02x_G6HteZHZ")); foreach (DriveItem item in response.DriveItems) { Console.WriteLine("Id: " + item.Id); Console.WriteLine("Name: " + item.Name); Console.WriteLine("WebUrl: " + item.WebUrl); if (item.FolderProperties != null) { Console.WriteLine("Folder: true"); } Console.WriteLine("-----------------------------------------------------------------"); } Console.Read(); } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Threading.Tasks Imports Independentsoft.Graph Imports Independentsoft.Graph.Files Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) ' Start and wait for task to end. task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Dim response As GetDriveItemsResponse = Await client.GetDriveItems("/", New DriveId("b!T7ZW_FMzJ02x_G6HteZHZ")) For Each item As DriveItem In response.DriveItems Console.WriteLine("Id: " & item.Id) Console.WriteLine("Name: " & item.Name) Console.WriteLine("WebUrl: " & item.WebUrl) If item.FolderProperties IsNot Nothing Then Console.WriteLine("Folder: true") End If Console.WriteLine("-----------------------------------------------------------------") Next Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*