Import text file to listbox (drive)

Asked

Viewed 62 times

1

Hello, I have tried to import a text file to a listbox by reading it row by row though, with the difference that this text file is not anywhere on the pc, but rather on my google drive. I’m using this code:

Dim R As IO.StreamReader
Dim Opt As String = web.DownloadString("https://drive.google.com/uc?authuser=0&id=(ID_AQUI)&export=download")

 R = New IO.StreamReader(Opt)
    While (R.Peek() > -1)
        ListBox1.Items.Add(R.ReadLine)
    End While
    R.Close()

However, when it tries to import, it returns the following error:

  • $Exception {"Invalid characters in path." } System.Argumentexception

And I already tried using System Encoding, and it did not solve my problem, I can make it work if I write first in a text file the contents of the google drive file, and then import the text file created, however, this is very slow, and I would like agility. If anyone can help me, I’d appreciate it.

  • Have you tried changing the Encoding of Webclient? Wb. Encoding = Encoding.UTF8.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.