Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

System.Net.WebException Error in Visual Basic

$
0
0
I've been getting an error with my code, and I'm not exactly sure as to how I can fix it. Here's my code:
Imports System.Net
Public Class Form1
    Dim streamer As IO.StreamReader
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim instance As WebClient = New WebClient
        Dim address As String = "https://my.file.here"
        Dim returnValue As String
        returnValue = instance.DownloadString(address)
        TextBox1.Text = returnValue
        Dim file As String = Application.StartupPath & "/numbers.txt"
        My.Computer.Network.DownloadFile("https://my.file.here", Application.StartupPath & "/numbers.txt", "", "", True, 100, True)
        streamer = IO.File.OpenText(Application.StartupPath & "/numbers.txt")
        Dim mystring() As String = streamer.ReadToEnd.Split(vbNewLine)
        ListBox1.Items.AddRange(mystring)
    End Sub
End Class


Basically, it gets a set of numbers off of my Dropbox, and reads them. It works fine, until I click the button a second time. Then I get this error: "An exception occurred during a WebClient request." It also says the file is in use. Thanks for any and all help! :)

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>