Windows Portable Devices can't re-create directory after deletion

Guillaume Doucet 25 Reputation points
2023-01-26T16:19:53.83+00:00

Hi,

I am using the documentation provided here: [https://learn.microsoft.com/en-us/windows/win32/wpd_sdk/wpd-application-programming-interface to create an interface to portable devices (Android device and memory sticks). I have implemented the provided example code into my application but I have an issue with re-creating a directory after the original one was deleted.

I can create a new directory on the device without issue. But if I navigate using windows explorer and delete the newly created directory or use pContent->Delete, I can't re-create a new one with the same name, using pContent->CreateObjectWithPropertiesOnly, unless I fully disconnect the device and connect it back again. I've gone through the documentation and can't find anything regarding "refreshing" the object list on the device. Am I overlooking something?

Thank you,

Guillaume D.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,527 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jeanine Zhang-MSFT 9,181 Reputation points Microsoft Vendor
    2023-01-27T01:41:29.1333333+00:00

    Hello,

    Welcome to Microsoft Q&A!

    According to the Doc: IPortableDeviceContent::CreateObjectWithPropertiesOnly method

    [in, out] ppszObjectID An optional string pointer to receive the name of the new object.
    The SDK allocates this memory; the caller must release it using CoTaskMemFree.

    I suggest you could try to use CoTaskMemFree function to release it. And then re-create a new one with the same name.

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful