Easy to use .NET Library for managing multiple Google Drive files. This library currently uses Google Drive Api v3
Follow these steps(Taken from google guide) to get your credentials from Google.
-
Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
-
On the Add credentials to your project page, click the Cancel button.
-
At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
-
Select the Credentials tab, click the Create credentials button and select OAuth client ID.
-
Select the application type Other, enter the name "Drive API Quickstart", and click the Create button.
-
Click OK to dismiss the resulting dialog.
-
Click the file_download (Download JSON) button to the right of the client ID.
-
Move this file to your working directory and rename it client_secret.json.
Reference the compiled class or insert the source class into your project.
There are 2 constructors for the base class.
LoggingEnabled is an optional parameter which enables logging to file.
- Uses client_secret.json file for credentials
NetGDrive drive = new NetGDrive("YourAppName");
- Uses client credentials from string parameter.
NetGDrive drive = new NetGDrive("YourAppName","YOUR_CLIENT_ID","YOUR_CLIENT_SECRET");
You can use chained methods to build a search parameter.
It supports all the operators and most of the fields from google drive but you can specify your own string so it shouldn't be a problem very much.
NetGSearchBuilder b = new NetGSearchBuilder();
b.AddField(Field.Name).Contains("SomeText").Or().AddField(Field.Name).Equal("SomeMoreText");
NetGDrive drive = new NetGDrive("YourAppName"); //This constructor uses client credentials from client_secret.json file.
var files = drive.GetFiles(b.Search);
foreach (var file in files)
{
Console.WriteLine(file.Name);
}
This project is licensed under the MIT License - see the LICENSE.md file for details.
Please dont hesitate to contact for any bugs or requests.