|Hi to all, I need to write inside a file located in a folder of my account in google drive and I wrote a desktop application in VB.net using Google Driver API v3. Since that me and my friend use the same account in different PC with the same VB.net application that I wrote, I need your help to to check if that file is opened by another user to avoid opening and garantee an "exclusive opening" on it.
I dont' know if google drive as an option to set an "exclusive opening" instead of API.
Maybe I can set permission to "read only" on the file when is opened by my application but I think it is not a good thing because if my application crashes (for example for a blackout) my file remain in read only state for always.
That's my routine that make a connection on my Google drive with my credentials, search for my folder and my file and give me back their ID:
Public Sub GoogleDrive()
Dim credential As UserCredential
Dim ID_Folder As String = ""
Dim ID_File As String = ""
Using Stream = New FileStream("credenzials.json", FileMode.Open, FileAccess.Read)
'The file token.json stores the user's access and refresh tokens, and is created
'automatically when the authorization flow completes for the first time.
Dim credPath As String = "token.json"
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
New FileDataStore(credPath, True)).Result
Console.WriteLine("Credential file saved to: " + credPath)
'Create Drive API service.
Dim Service = New DriveService(New BaseClientService.Initializer() With
.HttpClientInitializer = credential,
.ApplicationName = ApplicationName
' Define parameters of request.
Dim findrequest As FilesResource.ListRequest = Service.Files.List()
findrequest.PageSize = 10
findrequest.Fields = "nextPageToken, files(id, name)"
findrequest.Spaces = "drive"
Dim listFolder As Data.FileList = findrequest.Execute()
If listFolder.Files.Count > 0 Then
For Each item In listFolder.Files
If item.MimeType = "application/vnd.google-apps.folder" Then
If item.Name = "MyFolder" Then
ID_Folder = item.Id.ToString
If item.MimeType = "application/msaccess" Then
If item.Name = "myFile.mdb" Then
ID_File = item.Id.ToString
If (ID_File <> "") And (ID_Folder <> "") Then
'How check if ID_File is opened by an other user ?
Catch ex As Exception
Can someone help me ?