Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8724019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:44:39+00:00 2026-06-13T07:44:39+00:00

Im trying to do a FTPWEBREQUEST in a timer but I get this error

  • 0

Im trying to do a FTPWEBREQUEST in a timer but I get this error on TextBox1.Text = reader.ReadToEnd

Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'. 

can you help?

thanks

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Timer1.Stop()

        Dim request As FtpWebRequest = CType(WebRequest.Create(""), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.ListDirectoryDetails

        request.Credentials = New NetworkCredential("", "")
        Dim response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)

        Dim ResponseStream As Stream = response.GetResponseStream()
        Dim reader As New StreamReader(ResponseStream)

        'Console.Write(reader.ReadToEnd)
        'MessageBox.Show("Directory List Complete, status {0}", response.StatusDescription)


        'MessageBox.Show(reader.ReadToEnd)
        'MessageBox.Show(reader.ReadToEnd)

        TextBox1.Text = reader.ReadToEnd
        TextBox1.Text = vbNewLine
        TextBox1.Text = vbNewLine

        ResponseStream.Close()
        reader.Close()

        response.Close()






        reader.Close()
        response.Close()


        Timer1.Start()

    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:44:40+00:00Added an answer on June 13, 2026 at 7:44 am

    I don’t know your goal exactly and why you need a timer.

    But I want to give you some advices for you coding practice:

    You should not close (dispose) your streams twice. Use the Using statement for more clean and
    readable code. It also helps to release the resources early, even a exception is thrown.

    Public Class Form1    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load    
    
        End Sub    
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick    
    
            Timer1.Stop()    
    
             Dim request As FtpWebRequest = CType(WebRequest.Create(""), FtpWebRequest)
            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
    
            request.Credentials = New NetworkCredential("", "")
            Using response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
    
                Using responseStream As Stream = response.GetResponseStream()
                    Using reader As New StreamReader(responseStream)
    
    
                        TextBox1.Text = reader.ReadToEnd
                        TextBox1.Text += vbNewLine 
                        TextBox1.Text += vbNewLine
                        ' Use the + for appending (set the textbox to multiline)
    
                    End Using
    
                End Using
    
            End Using    
    
            Timer1.Start()    
    
        End Sub    
    End Class 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to install Text::Bidi CPAN module, but failed. Getting this error . Do anybody
Trying to find some information on this but am unable to get any results
Trying to get a wildcard search to pick up on any text in org_name
trying to figure out why this is happening - I have an input text
I'm trying to get a file via FTP per FtpWebrequest - the download fails
Trying to create a username/password validation form. getting the the following error Object variable
I'm trying to use an FtpWebRequest to get the size of a file on
trying to get my first HTML/CSS uni assignment sorted but have become a bit
Trying to develop hello world, but getting force close error on emulator. thanks in
trying to get a project working on my debian vm but foreman refuses to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.