A client recently informed me that after a docx was generated inside their SharePoint Online Document library, it wasn’t showing up on for up to 20 minutes in OneDrive. This was a problem for them as the docx was generated via custom code inside of SharePoint and they needed to work on it straight away. They also held a preference of working on it directly via OneDrive and not from SharePoint.

After speaking with Microsoft Support for an hour, the only help they could give me was it was working albeit slow, so they couldn’t help.

I then started scouring the internet and found that others were having this problem but there were no proper solutions. By pure trial an error I noticed that if I made a change to the One Drive folder, it would cause a re-sync and file would show up instantly. My guess is that OneDrive uses System.IO.FileSystemWatcher to let windows alert it of any changes to the folder, if the folder changes it then initiates a sync.

My first app attempt worked quiet well, I created a windows service which just edits a file inside of the OneDrive every 15 seconds, It would just change the content of  the 1kb file and this initiating a sync. The problem here was the file would be synced to the SharePoint Document library, and if multiple users worked on it, it would need to store multiple files inside the document library which are constantly updating. This was a possible solution but it I didn’t think the client would be happy with a bunch of random files generated in the document library

The next approach was to have a button in the File Explore Ribbon, “Refresh Onedrive”, which would create a random file in the one drive folder and then remove it. To my shock Windows 10 does not allow for extension to the Windows File Explorer ribbon. My next choice was to make a button which would be pined to the Taskbar.

The solution created requires the user to click a button in their taskbar anytime they wish to quickly refresh their onedrive folder, The solution is hacky and a little bit ugly, but works really well.

The Client was happy.

I bundled the app with an installer which can be downloaded from here: ForceSync

You can download or view the source here:

https://github.com/SharePointPro/One-Drive-Force-Sync

 

***UPDATE***

The day after I created this app, SharePoint & Onedrive seemed to be syncing instantly without assistance. A problem which was easy to replicate for a week before I coded the solution, has stopped being a problem. I’m unsure if Microsoft fixed something or if its an intermittent problem.