I need to create a virtual file system that syncs files from my Azure app service to local drive and backward. I need only some files and folders to be synchronized to my local file system and be available offline. The files/folders should synchronize during first access or when the user selects the "Always keep on this device" menu. Similar to how OneDrive is doing. I found the Microsoft CloudMirror C++ sample which has some basic OneDrive functionality, but it syncs all files one time during start and no listing/loading on first access.
Is it possible to build virtual file system with above functionality completely in .NET?
To build an OneDrive-like client you need to create the Sync Provider using cloud filter API, which is mostly programmable via Win32 (with some exceptions, see below), but you can build a complete OneDrive analog in .NET, including "Always keep on this device" menu and on-demand loading.
Here is the functionality that is available via .NET, so you do not need to PInvoke it:
Here is functionality available via Win32 functions only, you will need to call it via PInvoke:
Here is what you can do to write all code in .NET:
One option is to import all required Win32 functions using extern to .NET, for example:
Another option could be using this sample.
Some more notes on building an OneDrive-like file system: