Others

Get OneDrive File Availability Status in a C# Application

Rana GarciaRana Garcia Nov 20, 2026 868 views

Question details

Determine the device availability status of OneDrive files from a Windows C# application.

Get OneDrive File Availability Status in a 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.
Before you start

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.

Solution 1Recommended

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.

1
Get the local file path

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.

2
Check placeholder state

Retrieve the file's Windows find data and pass it to CfGetPlaceholderStateFromFindData. Inspect the returned placeholder state, including whether the file is partially hydrated.

3
Read pin and on-disk information

Open a handle to the file and call CfGetPlaceholderInfo with CF_PLACEHOLDER_INFO_STANDARD. Inspect PinState and OnDiskDataSize, and close the handle when finished.

4
Classify the result

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.

Inspect OneDrive placeholders with Windows Cloud Files APIs
Check the current device: Availability is device-specific and can change as OneDrive downloads or frees content. Empty files and API errors require special handling; do not classify a file solely from its on-disk size.
Free Microsoft Office alternative

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.

Open and edit Microsoft Word, Excel, and PowerPoint formatsWork with locally available Office documents from a OneDrive folderUse a familiar interface for a smoother transition from Microsoft OfficeGet a free, lightweight office suite for everyday work
microsoft office alternative - wps office

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.