Reputation: 141
Our custom-built software has a problem with the way Microsoft OneDrive locks and syncs files that's in use. Due to this we have decided not to support cloud save files. The idea is that when a user points a load or save at a location that syncs to cloud a popup will notify them that it's not supported.
My problem is identifying the said location. While the easiest way would be to look for the folder name 'OneDrive', I feel like that is not foolproof since the folder's name can be changed.
I thought about checking if the file has an 'availability status' since that shows in explorer if the file is in the cloud, local, or sync-enabled. Unfortunately I couldn't find any way to check that status other than visually, since I couldn't manually find references to the feature in the registry, command prompt or even the events log.
Example image:
Is there a command or method to find out this status of a file or folder like with the attrib
command? As a final resort, perhaps Powershell can solve my problem?
EDIT:
Gerhard Barnard's solution worked for me. Here's a visual.
(Thank you editors for turning these links into pictures while I rack up enough points for SO to trust me)
https://i.sstatic.net/u1NC2.jpg
https://i.sstatic.net/myyWz.jpg
This is also available using attrib
.
https://i.sstatic.net/Wv0ph.jpg
As mentioned by aschipfl, these features could possibly be absent on your system for reasons unknown as Microsoft's documentation seems outdated, however testing is underway.
EDIT2:
I believe for these features to be available you should have OneDrive installed. It generally runs from C:\Users[username]\AppData\Local\Microsoft\OneDrive\OneDrive.exe. I'm contemplating simply looking for this file instead of inspecting folder contents before saving and prompting my users.
Upvotes: 4
Views: 2643
Reputation:
a File attribute is set to offline when it is offline.. So you can get the attributes for files without the offline attribute set:
for /f "delims=" %%i in ('dir /b /a-o') do echo %%i Available file.
the opposite obviously with displaying files that are offline:
for /f "delims=" %%i in ('dir /b /a:o') do echo %%i Offline file.
to see more about attributes, from cmd.exe
run dir /?
and see the /A
switch help.
Upvotes: 2