Search code examples
c++windowssharedsmbfilehandle

Is there a way to open a file in a shared folder using the file id(FILE_ID_DESCRIPTOR) obtained from GetFileInformationByHandle()


Currently, i'm using the following functions to open the file using its id.

volHandle = CreateFile(pVolName, ...);
fileHandle = OpenFileById(volHandle, &id, ...)

The id(FILE_ID_DESCRIPTOR) is obtained from GetFinalPathNameByHandle().

This works for local files but when I tried it on a file in a shared folder(either from windows or unix machine), I get invalid volHandle.

Are there ways to open a file on a shared folder using its id(FILE_ID_DESCRIPTOR)?


Solution

  • From the documentation for OpenFileById, emphasis mine:

    In Windows 8 and Windows Server 2012, this function is supported by the following technologies.

    Technology Supported

    Server Message Block (SMB) 3.0 protocol - No

    In other words, you can't open a file by ID number over the network, only on a local file system.