Skip to content

Exception x80004005 “not allowed to write” when trying to (programmatically) eject a USB drive #7

@aliaga-d

Description

@aliaga-d

While using your code, and attempting to eject a USB drive (that has been being used for writing a zip file) the Eject function throws an exception.

I think here

int hr = Native.CM_Request_Device_Eject(device.InstanceHandle, out veto, sb, sb.Capacity, 0);
if (hr != 0)
        throw new Win32Exception(hr);

The exception reported is x80004005 "not allowed to write"

However if I do it again the ejection proceeds without problem. It is only the first time the exception is thrown. What could be the cause of this failure?
I would appreciate some help on this matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions