Independentsoft
Any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Move drive item
The following example shows you how to move a drive item to another folder.
C# example
using System; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Files; namespace Sample { class Program { static async Task Main(string[] args) { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; ItemReference destinationFolder = new ItemReference(); destinationFolder.Path = "/Folder2"; DriveItem movedItem = await client.MoveDriveItem("/Folder1/Test.pdf", "Test.pdf", destinationFolder, new DriveId("b!T7ZW_FMzJ02x_G6HteZHZ")); Console.WriteLine("Name = " + movedItem.Name); Console.Read(); } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports Independentsoft.Graph Imports Independentsoft.Graph.Files Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) 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 destinationFolder As ItemReference = New ItemReference() destinationFolder.Path = "/Folder2" Dim movedItem As DriveItem = Await client.MoveDriveItem("/Folder1/Test.pdf", "Test.pdf", destinationFolder, New DriveId("b!T7ZW_FMzJ02x_G6HteZHZ")) Console.WriteLine("Name = " & movedItem.Name) 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*