Use this tutorial to perform various operations on files and folders in AutoCAD 360 using the C# client.
After completing this tutorial, you would be able to:
- Connect to an AutoCAD 360 account.
- Query the file and folder directory for an account.
- Perform various operations like copy, move, delete, and create folder.
- Query file metadata.
- Launch a drawing in the AutoCAD 360 editor.
The C# Webdav client class relies on the standard WebDAV protocol to communicate with the AutoCAD 360 service.
Click here to download the C# sample application source code
The constructor of the Webdav client class expects three arguments:
- Host – specifies the WebDAV server address. For example, if you want to connect to AutoCAD 360 server, use: https://dav.autocadws.com.
- Username – specifies your AutoCAD 360 account.
- Password – specifies your AutoCAD 360 account password.
This sample code creates a new WebDAV client, connecting to the AutoCAD 360 server, with the username 'someuser' and password '123456':
Use the PROPFIND method to retrieve information about files and folders in AutoCAD 360.
PROPFIND / <handle>
The PROPFIND method receives two arguments:
- remoteFilePath – specifies the relative path to the folder/file for which we wish to retrieve information.
- depth – specifies whether the method is to be applied only to the resource (Depth = "0″), to the resource and its internal members only (Depth = "1″), or the resource and all its members (Depth = "infinity").
In addition, remember to subscribe your callback function to the PropfindComplete event.
Use this sample code, which sends a request to the AutoCAD 360 server for retrieving information about all files and folders within the Site directory:
In this example, we subscribe the function PropfindResponse to the PropfindComplete event. When Propfind is finished, Webdav client calls the PropfindResponse.
The following example shows a sample XML that the WebDAV server returns containing all the information about the files and folders.
The files/folders are returned in d:response tag. In this example, the server returns information about two files, 'filea.dwg' and 'fileb.dwg'. For each file, the server states the creation date and its name.
The following code demonstrates an implementation of thefunction that prints the names of all items retrieved to the console.
In this example, the user will see these file names printed to the console:
Use the PROPFIND method to copy, move, delete, and upload files.
Using this sample code, you can:
- Copy to
- Move to
- Upload a local file from to
You should subscribe a callback function to the appropriate event (, , , ). In these cases, there is no response to parse, but using the callback you will be notified when the operation is finished and whether it is was successful.
The following example shows thefunction that prints to console the message 'success' in case the request ended successfully or the message 'error' with the status code in case of an error:
Use themethod of your WebDAV client by passing the path of the drawing for opening the drawing.