Efficiently Managing Share with Me: Deleting Files in Google Drive


Google Drive API V3
Google Drive API V3


A are you trying to delete files from the Share with me folder on Google Drive? Do you just want to list the files in the share with me folder on Google Drive. I am going to show you how to do both of those things using the C# client library and the Google Drive V3 API.

About Share with me

The user doesn’t really own the files that appear in share with me. These are files that have been shared with the user they have access may have access to read or write to the file in question but they can not delete it as they do not own the file. That is why the following command will not work

service.Files.Delete(fileId).Execute();

How to remove a file from Share with me

In order to remove the file you must simply remove the permissions on the file granting the user access. The user does have access to remove the permissions on the file.

The Code

Note: This does not appear to work in all cases. I have a file on my Google drive that was shared with me by what appears to be a service account. I have no permissions on the file there for i cant remove my access. I am still digging.

Conclusion

It is possible to remove files from the share with me directory on Google drive. We simply remove our permissions on the file. I would like to thank KrishnaKanhaiya for asking this question on the site here and then posting it directly up on StackOver flow. This was a very good question and not something I have thought of trying before.


About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.