usbeject icon indicating copy to clipboard operation
usbeject copied to clipboard

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

Open aliaga-d opened this issue 6 years ago • 0 comments

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

aliaga-d avatar Nov 07 '18 21:11 aliaga-d