• About Morris Development
  • A Focus for Cloud Efficiency
    • Microsoft Azure
    • Amazon Web Services
  • What our Clients Say
  • Our Products
    • PreschoolDB
    • WebinarDB
  • Contact Us

Morris Development

Custom System Development and Integration

April 15, 2019

Using Google Drive API

Attached is a list of scripts we use in our webAPIs for managing files on Google Drive

Rename a File or Folder

var name = "some name";  //whatever you want to change the name to
var fileId = "OISDEF89SWE9023J2309D8DF"; //the ID of the folder or file you're renaming

Google.Apis.Drive.v3.Data.File file = new Google.Apis.Drive.v3.Data.File() { Name = name };
var updateRequest = service.Files.Update(file, fileId);
updateRequest.Fields = "name";
file = updateRequest.Execute();

So, here’s the deal: You make a new “File”. It’s just a class object that you’re creating, and all the google file properties are there. It’s about as basic as you can get when you think about it!

Once you make the object, you set the value of the field you want to change, which is simply the name of the file.

Now, you make a “request”, which is kind of like formulating a command from the service. You’re saying, here’s the fileID I want to modify and here’s a container that has the changes I want.

Then, you add the fields you want to modify, in this case, just the name. If it was a bunch, you just send a comma delimited string. That tells it, ok, here’s a class object with 1000 properties. Go to the “name” property and change it to what is contained in the update request. That way, you don’t need to tell Google to update the entire thing, just the ones you want.

So, it’s a simple solution, but honestly, it took me HOURS to figure it out because it’s just not listed anywhere!

I’m going to start putting in a list of other scripts we use as this system grows (if only for our own reference!)

Finding subfolders:

var q = string.Format("mimeType = 'application/vnd.google-apps.folder' and  '{0}' in parents", SomeFolderGoogleID);

Here’s HUGE heads-up. If you do it this way:

var q = string.Format("mimeType = 'application/vnd.google-apps.folder' and  parents in '{0}'", OfficeJobFolderID);

That works, and for SQL nerds like me, that makes sense BUT IT IS WRONG. Here’s the problem. We sometimes put a folder under multiple parents. If you do a query with “parents in XYZ”, it will show you the folders within that parent, but NOT the folders with that parent AND folder ABC. However, if you say “XYZ in parents”, it works fine. (that was 4 hours of my life right there!)

Article by MacGyver / Angular 2

About MacGyver

I've worked with database systems for over 20 years, and started my own company in 2000. Almost all my business consists of internal database systems, either ERP or CRM. My programming is primarily in Angular / Microsoft C# and MS SQL.

About This Site

Morris Development has been specializing in internal database system design and integration since 1999. We provide long-term management and support of secure data systems for many businesses as well as developing the more complex code structures for ERP systems like Intellievent, Apidas, and AVMS.

This site is primarily for our developers to keep track up various technologies and updates that are used by Morris Development.

Training

Integrating Angular Microsite with .Net

Private Data Caching with Google Storage

Continuous Deployment for Production Releases?

Azure Websites – the perfect Angular host

Angular 2

  • Angular 2 Authentication
  • Angular Command Line Interface
  • Material Design for Angular
  • Using Observables in Angular 2

Mentors

  • Ben Nadel
  • Dan Wahlin
  • Deborah Kurata
  • John Papa

Staff

  • Dan Morris

Training

  • Google Development Courses
  • Microsoft Virtual Academy
  • PluralSight
  • Test Deep Links

© 2025 · Morris Development