Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aliaga-d opened this issue Nov 7, 2018 · 0 comments

Comments

@aliaga-d
Copy link

aliaga-d commented Nov 7, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant