Get OneDrive File Availability Status in a C# Application
Question details
Determine the device availability status of OneDrive files from a Windows C# application.

- Product
- Microsoft OneDrive
- Device & OS
- Windows
- Scenario
- A developer needs to identify whether a OneDrive file is online-only, locally available, or always available on the device.
- Observed behavior
- The application should report each file's local availability and pinned state.
Confirm that OneDrive is syncing the files on the Windows device and identify their local paths. Check whether Files On-Demand is enabled and prepare to call Windows Cloud Files APIs through C# interop.
Inspect OneDrive placeholders with Windows Cloud Files APIs
Use Windows placeholder and pin information to determine a file's local availability on the current device.
OneDrive Files On-Demand uses Windows cloud-file placeholders. Hydration and pin state are separate: a pinned file may still be downloading, and an unpinned file may already have local content.
Cloud Files APIs are native Windows APIs, so a C# application needs appropriate P/Invoke declarations or a suitable interop library. Handle unsupported files, API errors, and state changes while OneDrive is syncing.
Identify the file under the user's synced OneDrive folder. Use its local path in your C# application rather than relying only on a OneDrive web URL.
Retrieve the file's Windows find data and pass it to CfGetPlaceholderStateFromFindData. Inspect the returned placeholder state, including whether the file is partially hydrated.
Open a handle to the file and call CfGetPlaceholderInfo with CF_PLACEHOLDER_INFO_STANDARD. Inspect PinState and OnDiskDataSize, and close the handle when finished.
Combine the placeholder, hydration, and pin information in your application: report a pinned and fully hydrated file as always available, an unpinned and fully hydrated file as locally available, and a placeholder without local content as online-only. Treat partially hydrated files and files still syncing as separate or transitional states.

Work with Office Files Using WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with existing Office files. Its format support makes it easy to move everyday document work from Microsoft Office, though it does not replace the Windows APIs needed to inspect OneDrive file availability.

Frequently Asked Questions
Does a pinned OneDrive file always have all its content downloaded?
Not necessarily. Check both PinState using CfGetPlaceholderInfo and the placeholder's hydration state; a pinned file may still be downloading.
Can a locally available file be unpinned?
Yes. OneDrive may keep an unpinned file's content locally until it is freed. Inspect both its pin and hydration states rather than using pin state alone.
Can I determine availability from the file's OneDrive web URL?
A web URL alone does not establish availability on a particular Windows device. Inspect the file at its local synced path using Windows Cloud Files APIs.
How do I call Cloud Files APIs from C#?
Use P/Invoke declarations or a suitable interop library for native functions such as CfGetPlaceholderInfo. Check returned HRESULT values and release any file handles your application opens.




