Click here to Skip to main content
15,885,998 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Question about creating dir Pin
Dave Kreskowiak19-Apr-22 11:21
mveDave Kreskowiak19-Apr-22 11:21 
QuestionApp.Path & "\" & App.EXEName alternative Pin
Everdome io5-Apr-22 2:08
Everdome io5-Apr-22 2:08 
AnswerRe: App.Path & "\" & App.EXEName alternative Pin
Richard Deeming5-Apr-22 2:25
mveRichard Deeming5-Apr-22 2:25 
GeneralRe: App.Path & "\" & App.EXEName alternative Pin
Everdome io5-Apr-22 5:04
Everdome io5-Apr-22 5:04 
AnswerRe: App.Path & "\" & App.EXEName alternative Pin
Raphael Adeniji17-Apr-22 10:31
Raphael Adeniji17-Apr-22 10:31 
Questionhow to add dynamic image in crystal report from vb6 Pin
Datta Bhor27-Mar-22 7:59
Datta Bhor27-Mar-22 7:59 
AnswerRe: how to add dynamic image in crystal report from vb6 Pin
Raphael Adeniji18-Apr-22 8:40
Raphael Adeniji18-Apr-22 8:40 
QuestionGoogle Drive API in VB.net check if file is opened Pin
Goldrake_Act23-Mar-22 21:47
Goldrake_Act23-Mar-22 21:47 
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(
GoogleClientSecrets.Load(Stream).Secrets,
Scopes,
"user",
CancellationToken.None,
New FileDataStore(credPath, True)).Result
Console.WriteLine("Credential file saved to: " + credPath)

End Using
'Create Drive API service.
Dim Service = New DriveService(New BaseClientService.Initializer() With
{
.HttpClientInitializer = credential,
.ApplicationName = ApplicationName
})
' Define parameters of request.
Try
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
End If
End If
'
If item.MimeType = "application/msaccess" Then
If item.Name = "myFile.mdb" Then
ID_File = item.Id.ToString
End If
End If

If (ID_File <> "") And (ID_Folder <> "") Then
'How check if ID_File is opened by an other user ?
Exit For
End If
Next
End If

Catch ex As Exception
'MsgBox(ex.Message)
Throw ex

End Try
End Sub

Can someone help me ?
Questionsearch for specific word in a text file Pin
Benjamindh19-Mar-22 18:09
Benjamindh19-Mar-22 18:09 
AnswerRe: search for specific word in a text file Pin
Richard MacCutchan19-Mar-22 22:17
mveRichard MacCutchan19-Mar-22 22:17 
AnswerRe: search for specific word in a text file Pin
Raphael Adeniji20-Apr-22 5:35
Raphael Adeniji20-Apr-22 5:35 
GeneralRe: search for specific word in a text file Pin
Richard Deeming20-Apr-22 6:11
mveRichard Deeming20-Apr-22 6:11 
GeneralRe: search for specific word in a text file Pin
Raphael Adeniji21-Apr-22 5:53
Raphael Adeniji21-Apr-22 5:53 
GeneralRe: search for specific word in a text file Pin
Richard Deeming21-Apr-22 6:53
mveRichard Deeming21-Apr-22 6:53 
GeneralRe: search for specific word in a text file Pin
Raphael Adeniji21-Apr-22 7:20
Raphael Adeniji21-Apr-22 7:20 
GeneralRe: search for specific word in a text file Pin
Richard Deeming21-Apr-22 21:20
mveRichard Deeming21-Apr-22 21:20 
QuestionRun .bat file from ftp using console apps Pin
SHAHROL AZMI BIN AMZAT13-Mar-22 21:07
SHAHROL AZMI BIN AMZAT13-Mar-22 21:07 
AnswerRe: Run .bat file from ftp using console apps Pin
Richard Deeming13-Mar-22 22:30
mveRichard Deeming13-Mar-22 22:30 
GeneralRe: Run .bat file from ftp using console apps Pin
SHAHROL AZMI BIN AMZAT15-Mar-22 13:14
SHAHROL AZMI BIN AMZAT15-Mar-22 13:14 
AnswerRe: Run .bat file from ftp using console apps Pin
Eddy Vluggen14-Mar-22 14:44
professionalEddy Vluggen14-Mar-22 14:44 
Questionconvert image to matrix Pin
CR7 Madara13-Mar-22 2:23
CR7 Madara13-Mar-22 2:23 
GeneralRe: convert image to matrix Pin
Richard MacCutchan13-Mar-22 2:32
mveRichard MacCutchan13-Mar-22 2:32 
AnswerRe: convert image to matrix Pin
Kenneth Haugland13-Mar-22 6:08
mvaKenneth Haugland13-Mar-22 6:08 
QuestionSimple question: why does Visual Studio "freak out" when changing Form1 name to something different Pin
lewist577-Mar-22 13:57
lewist577-Mar-22 13:57 
AnswerRe: Simple question: why does Visual Studio "freak out" when changing Form1 name to something different Pin
Richard MacCutchan7-Mar-22 21:21
mveRichard MacCutchan7-Mar-22 21:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.