Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Listing remote Directory

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    29

    Resolved [RESOLVED] [2005] Listing remote Directory

    Hi.. I'm new to visual basic, I'm now making a program to list files in remote directory, currently I'm using php to generate text file and my program to read the text file

    I want to read file line by line from http://localhost/tes/view.txt

    but it got stuck at this code
    Code:
    Dim objReader As New StreamReader("http://localhost/tes/view.txt")
    It said URI format not supported.. How to make it support? Is there some way to read remote file text?

    or is there some other way yo read files in directory?

    Thanks..

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] Listing remote Directory

    You need to use a WebClient to download that file, then read it using streamreader. Something like this:
    Code:
           Using WC As New System.Net.WebClient()
                Dim strem As IO.Stream = WC.OpenRead("put the address here")
                Using reader As New System.IO.StreamReader(strem)
                    Dim line As String = String.Empty
                    While reader.Peek >= 0
                        line = reader.ReadLine()
                        'Do whatever you want with that line here
                        '
                    End While
                End Using
            End Using
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    29

    Re: [2005] Listing remote Directory

    Quote Originally Posted by stanav
    You need to use a WebClient to download that file, then read it using streamreader. Something like this:
    Code:
           Using WC As New System.Net.WebClient()
                Dim strem As IO.Stream = WC.OpenRead("put the address here")
                Using reader As New System.IO.StreamReader(strem)
                    Dim line As String = String.Empty
                    While reader.Peek >= 0
                        line = reader.ReadLine()
                        'Do whatever you want with that line here
                        '
                    End While
                End Using
            End Using
    Thanks a lot it's working..

  4. #4
    New Member
    Join Date
    Dec 2008
    Posts
    2

    Re: [RESOLVED] [2005] Listing remote Directory

    Hi LeonLanford,

    you said you were trying to list remote directory with vb.net. I'm trying to do that but I haven´t found the way. Did you get it?

    Thanks

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    29

    Re: [RESOLVED] [2005] Listing remote Directory

    I'm using php to generate file about the files and directory there and read the generated file..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width