WebDAV Drive Sample for macOS in .NET, C#
This sample implements a virtual file system for macOS that displays documents from a WebDAV server. You can edit documents, upload and download documents as well as manage folders structure using macOS Finder. This sample supports synchronization, on-demand loading and selective offline files support. It synchronizes files and folders both from a WebDAV server to the local user file system and from the local user file system to the WebDAV server. This sample is written in .NET, C#.
You can use this sample out-of-the-box to manage documents on a WebDAV server, or you can use it as a starting point for your custom virtual drive to create OneDrive-like features for your DMS/CRM/ERP and reprogram it to publish data from your storage.
This sample is supplied as part of the SDK with IT Hit WebDAV Client Library for .NET and with IT Hit User File System.
You can download this sample and trial licenses in the IT Hit WebDAV Client Library product download area and in the IT Hit User File System product download area. You can also clone it or browse the code on GitHub.
This sample is provided with IT Hit User File System v6.2 and later versions.
- macOS 11.0+
- Mono 22.214.171.124+
- Xamarin.Mac: 126.96.36.199+
- Xcode 12.4+
- Visual Studio Community 2019 for Mac v8.8.10+, Stable Channel.
The macOS sample solution consists of 3 projects: container application, an extension project, and a common code.
The container application provides a Menu Bar icon to install/uninstall the file system extension.
The extension project runs in the background and implements a virtual file system on macOS (File Provider). It processes requests from macOS applications sent via macOS file system API and lists folders content. The macOS extension can be installed only as part of a container application, you can not install the extension application by itself.
Creating Group ID, App Identifies and Provisioning Profiles
In the following steps, we will describe how to configure and run this sample in the development environment. You will create an Apple group ID, Apple app identifies, and Apple provisioning profiles. Then you will update the sample container application project and extension project to use the created IDs and profiles.
Log-in to the Apple developer account here: https://developer.apple.com/. To complete the steps below you must have an App Manager role.
Create App Group. Navigate to Certificates, IDs, Profiles -> Identifiers -> App Groups and create a new group.
Create Apple macOS App IDs. Navigate to Certificates, IDs, Profile -> Identifiers -> App IDs. Create 2 identifiers that will be unique for your project. One will be used for container application another – for the extension.
Add app identifiers to the group. Add both identifiers created in Step 2 to the group created in Step 1. Select identifier and click on Edit. Then check the App Groups checkbox, select the Edit button and select the group created in Step 1.
Create Provisioning Profiles. Navigate to Certificates, Identifiers & Profiles -> Profiles -> Development and create profile. Associate profile with extension ID and container ID respectively.
Download profiles and certificates in XCode. Run XCode and go to Xcode Menu > Preferences -> Accounts tab. Select team and click on “Download Manual Profiles”. You can find more detailed instructions: here
Set bundle identifier name in Container project. The bundle identifier is located in WebDAVMacApp/Info.plist file. You can edit it either in Visual Studio or directly in Info.plist file in the CFBundleIdentifier field (by default it is set to com.userfilesystem.vfs.app). You must set this identifier to the value specified in Step 2.
Set bundle identifier name in the Extension project. The bundle identifier is located in WebDAVFileProviderExtension/Info.plist file. You can edit it either in Visual Studio or directly in Info.plist file in the CFBundleIdentifier field (by default it is set to com.userfilesystem.vfs.app.extension). You must set this identifier to the value specified in Step 2.
Configure macOS bundle signing in Container and Extension projects. For each project in Visual Studio go to the project Options. Select Mac Signing and check 'Sign the application bundle'. Select Identity and Provisioning profile.
Configure application permissions in Container and Extension projects. Select Entitlements.plist and select group created in Step 1 in App Groups field for each project.
Set App Group ID in code. Edit AppGroupsSettings.cs file located in /WebDAVCommon/ folder. Specify AppGroupId.
Setting the License
Note that to use the sample you need both the IT Hit WebDAV Client Library license and IT Hit User File System license.
To run the example, you will need both IT Hit WebDAV Client Library for .NET license and IT Hit User File System Engine for .NET License. You can download a WebDAV Client for .NET trial license in the IT Hit WebDAV Client Library product download area and the User File System trial license in the IT Hit User File System product download area. Note that this sample is fully functional with a trial licenses and does not have any limitations. The trial licenses are valid for one month will stop working after this. You can check the expiration date inside the license file. Download the license files and specify license strings in the WebDAVClientLicense and UserFileSystemLicense fields respectively in WebDAVMacApp\Resources\appsettings.json file. Set the license content directly as a value (NOT as a path to the license file). Do not forget to escape quotes: \":
"UserFileSystemLicense": "<?xml version=\"1.0\" encoding=\"utf-8\"?><License…
You can also run the sample without explicitly specifying a license for 5 days. In this case, the Engine will automatically request the trial licenses from the IT Hit website https://www.userfilesystem.com. Make sure it is accessible via firewalls if any. After 5 days the Engine will stop working. To extend the trial period you will need to download trial licenses and specify them in appsettings.json
Setting WebDAV Server URL
To specify the WebDAV server URL edit the "WebDAVServerUrl" parameter in appsettings.json. This could be either a server root path (https://server/) or a WebDAV folder on your server (https://server/dav/).
For testing and demo purposes you can use one of the IT Hit demo servers. Navigate to https://webdavserver.net or to https://webdavserver.com in a web browser. Copy the URL or your test folder, that looks like https://webdavserver.net/User123456/ and specify it in the WebDAVServerUrl parameter.
Running the Sample
To run the sample
- Open the project in Visual Studio and run the project. The application is added the macOS Status Bar.
- Select 'Install Extension' command in the Status Bar. This will mount your WebDAV file system.
Now you can manage documents using Finder, command prompt or by any other means. You can find the new file system in the 'Locations' sections in Finder.