Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I want to know how i found if folder exixt or not in google drive with vb.net . i searched many tutorial and page and i can't do it

What I have tried:

i think i will do a list of folder ,and if my folder exist in list , messagebox will show exist message else my folder will be upload in drive . the problem is how i do it , i'm very very stuck
Posted
Updated 26-Jul-17 23:10pm
v2

1 solution

The Google Drive List command has a query parameter: Files: list  |  Drive REST API v2  |  Google Developers[^]

More information here on how to query: Search for Files  |  Drive REST API v2  |  Google Developers[^]

Note: Files and folders use the same API endpoints, the mimetype determines if it is a folder or a file. More information here: Work with Folders  |  Drive REST API v2  |  Google Developers[^]

UPDATE: As per the Search for Files  |  Drive REST API v2  |  Google Developers[^], searching for a folder:
"mimeType = 'application/vnd.google-apps.folder' AND name = '[foldername]'"

Please take the time to read the documentation and the excellent examples given by Google.
 
Share this answer
 
v6
Comments
Member 8587273 27-Jul-17 6:11am    
I tried to integrate this code in my application .
I create a new boolean function which return false if folder exist
and i call it in another methode , but i have an exception

Google.GoogleApiException : 'Google.Apis.Requests.RequestError

Invalid query [400]

Errors [

Message[Invalid query] Location[q - parameter] Reason[invalid] Domain[global]

]



here is my function method code

Public Function exist(v As String) As Boolean
Dim pag As String
Dim req = Service.Files.List()
req.Q = "application/vnd.google-apps.folder"
req.PageToken = pag
Dim result = req.Execute()
If (result.NextPageToken IsNot Nothing) Then
Return False
Else
Return True
End If

End Function


here where i call it

If (exist(dat_sauv.SelectedItem) = False) Then
MessageBox.Show("folder exist already")

End If

the exception has declenched in this line (exist method)

Dim result = req.Execute()
Graeme_Grant 27-Jul-17 6:14am    
Please don't post code in replies as it is too difficult to read. Instead, post in the question. Here are instructions on how: Code Project Quick Answers FAQ[^]
Graeme_Grant 27-Jul-17 6:16am    
"Message[Invalid query] Location[q - parameter] Reason[invalid] Domain[global]" - your query param is not correctly formed. Start with simple queries first, then work towards your complex/advanced query.
Member 8587273 27-Jul-17 6:27am    
thanks , i post my code in another Question
Graeme_Grant 27-Jul-17 7:00am    
The other question was closed as it is the same as this one. Please following the posting guidelines as outlined in the FAQ.

As mentioned above, you need to read the documentation: Search for Files  |  Drive REST API v2  |  Google Developers[^] - the documentation clearly explains how to query (Google query language) for folders or files and how to search the name field - see the section labeled EXAMPLES.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900