I am trying to work with Google Drive API with vb.net.
I have seen a lot of posts,but I am not able to understand how to choose the right folder to add a file.
I have a lot of "Backup" folders but, I assume now, I want to add a file into "Backup" folder under "MyApp1" folder.
I am doing it this way but I don't know how to continue. I search all of my "Backup" folder and I need to check which is under parent folder "Myapp".
Public Shared Function TheRightFolder() As Boolean
Dim FolderName As String = "Backup"
Dim ParentName As String = "MyAPP1"
Dim result As Boolean = False
Dim request = Service.Files.List()
Dim requeststring As String = ("mimeType='application/vnd.google-apps.folder' And trashed=false and title='" & FolderName & "'")
request.Q = requeststring
Dim Parent = request.Execute()
For Each item As File In Parent.Items
'Get PARENT NAME OF THE FOLDER TO CHECK IF I AM INSERT IN MY FILE IN THE RIGHT DIRECTORY (USING 'item.Parents DATA'?)
If ParentName = new_func_to_get_parent_folder_name Then
Catch EX As Exception
MsgBox("ERROR" & EX.Message)
Public Shared Sub ParentsInFolder(ByVal folderId As String) Dim request As ParentsResource.ListRequest = Service.Parents.List(folderId) Try Dim parents As ParentList = request.Execute() For Each parent As ParentReference In parents.Items Dim FileId As String = parent.Id.ToString InfoFromID(Service, FileId) Next Catch e As Exception MsgBox("Errore: " & e.Message) End Try End Sub
Public Shared Sub InfoFromID(ByVal Service As DriveService, fileId As String) Try Dim file As File = service.Files.Get(fileId).Execute Dim Title As String = file.Title Dim MimeType As String = file.MimeType.ToString Dim description As String = file.Description Catch e As Exception MsgBox("Errore: " + e.Message) End Try End Sub